WithoutContentTransformations() private method

Used by SprEngine internally; do not use.
private WithoutContentTransformations ( ) : SprContext
return SprContext
コード例 #1
0
		private static string ReplacePickPwPlaceholder(string str,
			string strPlaceholder, uint uCharCount, SprContext ctx,
			uint uRecursionLevel)
		{
			if(str.IndexOf(strPlaceholder, StrUtil.CaseIgnoreCmp) < 0) return str;

			ProtectedString ps = ctx.Entry.Strings.Get(PwDefs.PasswordField);
			if(ps != null)
			{
				string strPassword = ps.ReadString();

				string strPick = SprEngine.CompileInternal(strPassword,
					ctx.WithoutContentTransformations(), uRecursionLevel + 1);

				if(!string.IsNullOrEmpty(strPick))
				{
					ProtectedString psPick = new ProtectedString(false, strPick);
					string strPicked = (CharPickerForm.ShowAndRestore(psPick,
						true, true, uCharCount, null) ?? string.Empty);

					str = StrUtil.ReplaceCaseInsensitive(str, strPlaceholder,
						SprEngine.TransformContent(strPicked, ctx));
				}
			}

			return StrUtil.ReplaceCaseInsensitive(str, strPlaceholder, string.Empty);
		}
コード例 #2
0
        private static string ReplacePickPwPlaceholder(string str,
                                                       string strPlaceholder, uint uCharCount, SprContext ctx,
                                                       uint uRecursionLevel)
        {
            if (str.IndexOf(strPlaceholder, StrUtil.CaseIgnoreCmp) < 0)
            {
                return(str);
            }

            ProtectedString ps = ctx.Entry.Strings.Get(PwDefs.PasswordField);

            if (ps != null)
            {
                string strPassword = ps.ReadString();

                string strPick = SprEngine.CompileInternal(strPassword,
                                                           ctx.WithoutContentTransformations(), uRecursionLevel + 1);

                if (!string.IsNullOrEmpty(strPick))
                {
                    ProtectedString psPick    = new ProtectedString(false, strPick);
                    string          strPicked = (CharPickerForm.ShowAndRestore(psPick,
                                                                               true, true, uCharCount, null) ?? string.Empty);

                    str = StrUtil.ReplaceCaseInsensitive(str, strPlaceholder,
                                                         SprEngine.TransformContent(strPicked, ctx));
                }
            }

            return(StrUtil.ReplaceCaseInsensitive(str, strPlaceholder, string.Empty));
        }
コード例 #3
0
        private static string Fill(string strData, string strPlaceholder,
                                   string strReplacement, SprContext ctx, uint?ouRecursionLevel)
        {
            if (strData == null)
            {
                Debug.Assert(false); return(string.Empty);
            }
            if (string.IsNullOrEmpty(strPlaceholder))
            {
                Debug.Assert(false); return(strData);
            }
            if (strReplacement == null)
            {
                Debug.Assert(false); strReplacement = string.Empty;
            }

            if (strData.IndexOf(strPlaceholder, SprEngine.ScMethod) < 0)
            {
                return(strData);
            }

            string strValue = strReplacement;

            if (ouRecursionLevel.HasValue)
            {
                strValue = SprEngine.CompileInternal(strValue, ((ctx != null) ?
                                                                ctx.WithoutContentTransformations() : null),
                                                     ouRecursionLevel.Value + 1);
            }

            return(StrUtil.ReplaceCaseInsensitive(strData, strPlaceholder,
                                                  SprEngine.TransformContent(strValue, ctx)));
        }
コード例 #4
0
        private static string ShowCharPickDlg(string strWord, uint uCharCount,
                                              bool?bInitHide, SprContext ctx, uint uRecursionLevel)
        {
            string strPick = SprEngine.CompileInternal(strWord,
                                                       ctx.WithoutContentTransformations(), uRecursionLevel + 1);

            // No need to show the dialog when there's nothing to pick from
            // (this also prevents the dialog from showing up MaxRecursionDepth
            // times in case of a cyclic {PICKCHARS})
            if (string.IsNullOrEmpty(strPick))
            {
                return(string.Empty);
            }

            CharPickerForm cpf = new CharPickerForm();

            cpf.InitEx(new ProtectedString(false, strPick), true, true,
                       uCharCount, bInitHide);

            string strResult = string.Empty;

            if (cpf.ShowDialog() == DialogResult.OK)
            {
                strResult = cpf.SelectedCharacters.ReadString();
            }

            UIUtil.DestroyForm(cpf);
            return(strResult);            // Don't transform here
        }
コード例 #5
0
        private static string PerformClipboardCopy(string strText, SprContext ctx,
                                                   uint uRecursionLevel)
        {
            string        str = strText;
            int           iStart;
            List <string> lParams;
            SprContext    ctxData = ((ctx != null) ? ctx.WithoutContentTransformations() : null);

            while (ParseAndRemovePlhWithParams(ref str, ctxData, uRecursionLevel,
                                               @"{CLIPBOARD-SET:", out iStart, out lParams, true))
            {
                if (lParams.Count < 1)
                {
                    continue;
                }

                try
                {
                    ClipboardUtil.Copy(lParams[0] ?? string.Empty, false,
                                       true, null, null, IntPtr.Zero);
                }
                catch (Exception) { Debug.Assert(false); }
            }

            return(str);
        }
コード例 #6
0
        private static string FillIfExists(string strData, string strPlaceholder,
                                           ProtectedString psParsable, SprContext ctx, uint uRecursionLevel)
        {
            // The UrlRemoveSchemeOnce property of ctx must be cleared
            // before this method returns and before any recursive call
            bool bRemoveScheme = false;

            if (ctx != null)
            {
                bRemoveScheme           = ctx.UrlRemoveSchemeOnce;
                ctx.UrlRemoveSchemeOnce = false;
            }

            if (strData == null)
            {
                Debug.Assert(false); return(string.Empty);
            }
            if (strPlaceholder == null)
            {
                Debug.Assert(false); return(strData);
            }
            if (strPlaceholder.Length == 0)
            {
                Debug.Assert(false); return(strData);
            }
            if (psParsable == null)
            {
                Debug.Assert(false); return(strData);
            }

            if (strData.IndexOf(strPlaceholder, SprEngine.ScMethod) >= 0)
            {
                string strReplacement = SprEngine.CompileInternal(
                    psParsable.ReadString(), ctx.WithoutContentTransformations(),
                    uRecursionLevel + 1);

                if (bRemoveScheme)
                {
                    strReplacement = UrlUtil.RemoveScheme(strReplacement);
                }

                return(SprEngine.FillPlaceholder(strData, strPlaceholder,
                                                 strReplacement, ctx));
            }

            return(strData);
        }
コード例 #7
0
        private static string ShowCharPickDlg(string strWord, uint uCharCount,
                                              bool?bInitHide, SprContext ctx, uint uRecursionLevel)
        {
            string strPick = SprEngine.CompileInternal(strWord,
                                                       ctx.WithoutContentTransformations(), uRecursionLevel + 1);

            // No need to show the dialog when there's nothing to pick from
            // (this also prevents the dialog from showing up MaxRecursionDepth
            // times in case of a cyclic {PICKCHARS})
            if (string.IsNullOrEmpty(strPick))
            {
                return(string.Empty);
            }

            ProtectedString psWord    = new ProtectedString(false, strPick);
            string          strPicked = CharPickerForm.ShowAndRestore(psWord,
                                                                      true, true, uCharCount, bInitHide);

            return(strPicked ?? string.Empty);              // Don't transform here
        }
コード例 #8
0
ファイル: SprEngine.cs プロジェクト: sinelaw/keepass
        private static string FillEntryStringsSpecial(string str, SprContext ctx,
                                                      uint uRecursionLevel)
        {
            if ((str.IndexOf(UrlSpecialRmvScm, SprEngine.ScMethod) >= 0) ||
                (str.IndexOf(UrlSpecialScm, SprEngine.ScMethod) >= 0) ||
                (str.IndexOf(UrlSpecialHost, SprEngine.ScMethod) >= 0) ||
                (str.IndexOf(UrlSpecialPort, SprEngine.ScMethod) >= 0) ||
                (str.IndexOf(UrlSpecialPath, SprEngine.ScMethod) >= 0) ||
                (str.IndexOf(UrlSpecialQuery, SprEngine.ScMethod) >= 0))
            {
                SprContext ctxRaw = ctx.WithoutContentTransformations();
                string     strUrl = SprEngine.FillIfExists(@"{URL}", @"{URL}",
                                                           ctx.Entry.Strings.GetSafe(PwDefs.UrlField), ctxRaw, uRecursionLevel);

                str = SprEngine.FillPlaceholder(str, UrlSpecialRmvScm,
                                                UrlUtil.RemoveScheme(strUrl), ctx);

                try
                {
                    Uri uri = new Uri(strUrl);

                    str = SprEngine.FillPlaceholder(str, UrlSpecialScm,
                                                    uri.Scheme, ctx);
                    str = SprEngine.FillPlaceholder(str, UrlSpecialHost,
                                                    uri.Host, ctx);
                    str = SprEngine.FillPlaceholder(str, UrlSpecialPort,
                                                    uri.Port.ToString(NumberFormatInfo.InvariantInfo), ctx);
                    str = SprEngine.FillPlaceholder(str, UrlSpecialPath,
                                                    uri.AbsolutePath, ctx);
                    str = SprEngine.FillPlaceholder(str, UrlSpecialQuery,
                                                    uri.Query, ctx);
                }
                catch (Exception) { }                // Invalid URI
            }

            return(str);
        }
コード例 #9
0
ファイル: SprEngine.cs プロジェクト: dbremner/keepass2
		private static string FillRefPlaceholders(string strSeq, SprContext ctx,
			uint uRecursionLevel)
		{
			if(ctx.Database == null) return strSeq;

			string str = strSeq;

			int nOffset = 0;
			for(int iLoop = 0; iLoop < 20; ++iLoop)
			{
				str = SprEngine.FillRefsUsingCache(str, ctx);

				int nStart = str.IndexOf(StrRefStart, nOffset, SprEngine.ScMethod);
				if(nStart < 0) break;
				int nEnd = str.IndexOf(StrRefEnd, nStart + 1, SprEngine.ScMethod);
				if(nEnd <= nStart) break;

				string strFullRef = str.Substring(nStart, nEnd - nStart + 1);
				char chScan, chWanted;
				PwEntry peFound = FindRefTarget(strFullRef, ctx, out chScan, out chWanted);

				if(peFound != null)
				{
					string strInsData;
					if(chWanted == 'T')
						strInsData = peFound.Strings.ReadSafe(PwDefs.TitleField);
					else if(chWanted == 'U')
						strInsData = peFound.Strings.ReadSafe(PwDefs.UserNameField);
					else if(chWanted == 'A')
						strInsData = peFound.Strings.ReadSafe(PwDefs.UrlField);
					else if(chWanted == 'P')
						strInsData = peFound.Strings.ReadSafe(PwDefs.PasswordField);
					else if(chWanted == 'N')
						strInsData = peFound.Strings.ReadSafe(PwDefs.NotesField);
					else if(chWanted == 'I')
						strInsData = peFound.Uuid.ToHexString();
					else { nOffset = nStart + 1; continue; }

					if((chWanted == 'P') && !ctx.ForcePlainTextPasswords &&
						Program.Config.MainWindow.IsColumnHidden(AceColumnType.Password))
						strInsData = PwDefs.HiddenPassword;

					SprContext sprSub = ctx.WithoutContentTransformations();
					sprSub.Entry = peFound;

					string strInnerContent = SprEngine.CompileInternal(strInsData,
						sprSub, uRecursionLevel + 1);
					strInnerContent = SprEngine.TransformContent(strInnerContent, ctx);

					// str = str.Substring(0, nStart) + strInnerContent + str.Substring(nEnd + 1);
					SprEngine.AddRefToCache(strFullRef, strInnerContent, ctx);
					str = SprEngine.FillRefsUsingCache(str, ctx);
				}
				else { nOffset = nStart + 1; continue; }
			}

			return str;
		}
コード例 #10
0
ファイル: SprEngine.cs プロジェクト: dbremner/keepass2
		/// <summary>
		/// Parse and remove a placeholder of the form
		/// <c>{PLH:/Param1/Param2/.../}</c>.
		/// </summary>
		internal static bool ParseAndRemovePlhWithParams(ref string str,
			SprContext ctx, uint uRecursionLevel, string strPlhStart,
			out int iStart, out List<string> lParams, bool bSprCmpParams)
		{
			Debug.Assert(strPlhStart.StartsWith(@"{") && !strPlhStart.EndsWith(@"}"));

			iStart = str.IndexOf(strPlhStart, StrUtil.CaseIgnoreCmp);
			if(iStart < 0) { lParams = null; return false; }

			lParams = new List<string>();

			try
			{
				int p = iStart + strPlhStart.Length;
				if(p >= str.Length) throw new FormatException();

				char chSep = str[p];

				while(true)
				{
					if((p + 1) >= str.Length) throw new FormatException();

					if(str[p + 1] == '}') break;

					int q = str.IndexOf(chSep, p + 1);
					if(q < 0) throw new FormatException();

					lParams.Add(str.Substring(p + 1, q - p - 1));
					p = q;
				}

				Debug.Assert(str[p + 1] == '}');
				str = str.Remove(iStart, (p + 1) - iStart + 1);
			}
			catch(Exception)
			{
				str = str.Substring(0, iStart);
			}

			if(bSprCmpParams && (ctx != null))
			{
				SprContext ctxSub = ctx.WithoutContentTransformations();
				for(int i = 0; i < lParams.Count; ++i)
					lParams[i] = CompileInternal(lParams[i], ctxSub, uRecursionLevel);
			}

			return true;
		}
コード例 #11
0
ファイル: SprEngine.cs プロジェクト: dbremner/keepass2
		private static string FillIfExists(string strData, string strPlaceholder,
			ProtectedString psParsable, SprContext ctx, uint uRecursionLevel)
		{
			// // The UrlRemoveSchemeOnce property of ctx must be cleared
			// // before this method returns and before any recursive call
			// bool bRemoveScheme = false;
			// if(ctx != null)
			// {
			//	bRemoveScheme = ctx.UrlRemoveSchemeOnce;
			//	ctx.UrlRemoveSchemeOnce = false;
			// }

			if(strData == null) { Debug.Assert(false); return string.Empty; }
			if(strPlaceholder == null) { Debug.Assert(false); return strData; }
			if(strPlaceholder.Length == 0) { Debug.Assert(false); return strData; }
			if(psParsable == null) { Debug.Assert(false); return strData; }

			if(strData.IndexOf(strPlaceholder, SprEngine.ScMethod) >= 0)
			{
				string strReplacement = SprEngine.CompileInternal(
					psParsable.ReadString(), ctx.WithoutContentTransformations(),
					uRecursionLevel + 1);

				// if(bRemoveScheme)
				//	strReplacement = UrlUtil.RemoveScheme(strReplacement);

				return SprEngine.FillPlaceholder(strData, strPlaceholder,
					strReplacement, ctx);
			}

			return strData;
		}
コード例 #12
0
ファイル: SprEngine.cs プロジェクト: dbremner/keepass2
		private static string FillUriSpecial(string strText, SprContext ctx,
			string strPlhInit, string strData, bool bDataIsEncoded,
			uint uRecursionLevel)
		{
			Debug.Assert(strPlhInit.StartsWith(@"{") && !strPlhInit.EndsWith(@"}"));
			Debug.Assert(strData != null);

			string[] vPlhs = new string[] {
				strPlhInit + @"}",
				strPlhInit + @":RMVSCM}",
				strPlhInit + @":SCM}",
				strPlhInit + @":HOST}",
				strPlhInit + @":PORT}",
				strPlhInit + @":PATH}",
				strPlhInit + @":QUERY}",
				strPlhInit + @":USERINFO}",
				strPlhInit + @":USERNAME}",
				strPlhInit + @":PASSWORD}"
			};

			string str = strText;
			string strDataCmp = null;
			Uri uri = null;
			for(int i = 0; i < vPlhs.Length; ++i)
			{
				string strPlh = vPlhs[i];
				if(str.IndexOf(strPlh, SprEngine.ScMethod) < 0) continue;

				if(strDataCmp == null)
				{
					SprContext ctxData = (bDataIsEncoded ?
						ctx.WithoutContentTransformations() : ctx);
					strDataCmp = SprEngine.CompileInternal(strData, ctxData,
						uRecursionLevel + 1);
				}

				string strRep = null;
				if(i == 0) strRep = strDataCmp;
				else if(i == 1) strRep = UrlUtil.RemoveScheme(strDataCmp);
				else
				{
					try
					{
						if(uri == null) uri = new Uri(strDataCmp);

						int t;
						switch(i)
						{
							case 2: strRep = uri.Scheme; break;
							case 3: strRep = uri.Host; break;
							case 4:
								strRep = uri.Port.ToString(
									NumberFormatInfo.InvariantInfo);
								break;
							case 5: strRep = uri.AbsolutePath; break;
							case 6: strRep = uri.Query; break;
							case 7: strRep = uri.UserInfo; break;
							case 8:
								strRep = uri.UserInfo;
								t = strRep.IndexOf(':');
								if(t >= 0) strRep = strRep.Substring(0, t);
								break;
							case 9:
								strRep = uri.UserInfo;
								t = strRep.IndexOf(':');
								if(t < 0) strRep = string.Empty;
								else strRep = strRep.Substring(t + 1);
								break;
							default: Debug.Assert(false); break;
						}
					}
					catch(Exception) { } // Invalid URI
				}
				if(strRep == null) strRep = string.Empty; // No assert

				str = StrUtil.ReplaceCaseInsensitive(str, strPlh, strRep);
			}

			return str;
		}
コード例 #13
0
        /// <summary>
        /// Parse and remove a placeholder of the form
        /// <c>{PLH:/Param1/Param2/.../}</c>.
        /// </summary>
        internal static bool ParseAndRemovePlhWithParams(ref string str,
                                                         SprContext ctx, uint uRecursionLevel, string strPlhStart,
                                                         out int iStart, out List <string> lParams, bool bSprCmpParams)
        {
            Debug.Assert(strPlhStart.StartsWith(@"{") && !strPlhStart.EndsWith(@"}"));

            iStart = str.IndexOf(strPlhStart, SprEngine.ScMethod);
            if (iStart < 0)
            {
                lParams = null; return(false);
            }

            lParams = new List <string>();

            try
            {
                int p = iStart + strPlhStart.Length;
                if (p >= str.Length)
                {
                    throw new FormatException();
                }

                char chSep = str[p];

                while (true)
                {
                    if ((p + 1) >= str.Length)
                    {
                        throw new FormatException();
                    }

                    if (str[p + 1] == '}')
                    {
                        break;
                    }

                    int q = str.IndexOf(chSep, p + 1);
                    if (q < 0)
                    {
                        throw new FormatException();
                    }

                    lParams.Add(str.Substring(p + 1, q - p - 1));
                    p = q;
                }

                Debug.Assert(str[p + 1] == '}');
                str = str.Remove(iStart, (p + 1) - iStart + 1);
            }
            catch (Exception)
            {
                str = str.Substring(0, iStart);
            }

            if (bSprCmpParams && (ctx != null))
            {
                SprContext ctxSub = ctx.WithoutContentTransformations();
                for (int i = 0; i < lParams.Count; ++i)
                {
                    lParams[i] = CompileInternal(lParams[i], ctxSub, uRecursionLevel);
                }
            }

            return(true);
        }
コード例 #14
0
        private static string FillRefPlaceholders(string strSeq, SprContext ctx,
                                                  uint uRecursionLevel)
        {
            if (ctx.Database == null)
            {
                return(strSeq);
            }

            string str = strSeq;

            int nOffset = 0;

            for (int iLoop = 0; iLoop < 20; ++iLoop)
            {
                str = ctx.RefCache.Fill(str, ctx);

                int nStart = str.IndexOf(StrRefStart, nOffset, SprEngine.ScMethod);
                if (nStart < 0)
                {
                    break;
                }
                int nEnd = str.IndexOf(StrRefEnd, nStart + 1, SprEngine.ScMethod);
                if (nEnd <= nStart)
                {
                    break;
                }

                string  strFullRef = str.Substring(nStart, nEnd - nStart + 1);
                char    chScan, chWanted;
                PwEntry peFound = FindRefTarget(strFullRef, ctx, out chScan, out chWanted);

                if (peFound != null)
                {
                    string strInsData;
                    if (chWanted == 'T')
                    {
                        strInsData = peFound.Strings.ReadSafe(PwDefs.TitleField);
                    }
                    else if (chWanted == 'U')
                    {
                        strInsData = peFound.Strings.ReadSafe(PwDefs.UserNameField);
                    }
                    else if (chWanted == 'A')
                    {
                        strInsData = peFound.Strings.ReadSafe(PwDefs.UrlField);
                    }
                    else if (chWanted == 'P')
                    {
                        strInsData = peFound.Strings.ReadSafe(PwDefs.PasswordField);
                    }
                    else if (chWanted == 'N')
                    {
                        strInsData = peFound.Strings.ReadSafe(PwDefs.NotesField);
                    }
                    else if (chWanted == 'I')
                    {
                        strInsData = peFound.Uuid.ToHexString();
                    }
                    else
                    {
                        nOffset = nStart + 1; continue;
                    }

                    if ((chWanted == 'P') && !ctx.ForcePlainTextPasswords &&
                        Program.Config.MainWindow.IsColumnHidden(AceColumnType.Password))
                    {
                        strInsData = PwDefs.HiddenPassword;
                    }

                    SprContext sprSub = ctx.WithoutContentTransformations();
                    sprSub.Entry = peFound;

                    string strInnerContent = SprEngine.CompileInternal(strInsData,
                                                                       sprSub, uRecursionLevel + 1);
                    strInnerContent = SprEngine.TransformContent(strInnerContent, ctx);

                    // str = str.Substring(0, nStart) + strInnerContent + str.Substring(nEnd + 1);
                    ctx.RefCache.Add(strFullRef, strInnerContent, ctx);
                    str = ctx.RefCache.Fill(str, ctx);
                }
                else
                {
                    nOffset = nStart + 1; continue;
                }
            }

            return(str);
        }
コード例 #15
0
        private static string FillUriSpecial(string strText, SprContext ctx,
                                             string strPlhInit, string strData, bool bDataIsEncoded,
                                             uint uRecursionLevel)
        {
            Debug.Assert(strPlhInit.StartsWith(@"{") && !strPlhInit.EndsWith(@"}"));
            Debug.Assert(strData != null);

            string[] vPlhs = new string[] {
                strPlhInit + @"}",
                strPlhInit + @":RMVSCM}",
                strPlhInit + @":SCM}",
                strPlhInit + @":HOST}",
                strPlhInit + @":PORT}",
                strPlhInit + @":PATH}",
                strPlhInit + @":QUERY}",
                strPlhInit + @":USERINFO}",
                strPlhInit + @":USERNAME}",
                strPlhInit + @":PASSWORD}"
            };

            string str        = strText;
            string strDataCmp = null;
            Uri    uri        = null;

            for (int i = 0; i < vPlhs.Length; ++i)
            {
                string strPlh = vPlhs[i];
                if (str.IndexOf(strPlh, SprEngine.ScMethod) < 0)
                {
                    continue;
                }

                if (strDataCmp == null)
                {
                    SprContext ctxData = (bDataIsEncoded ?
                                          ctx.WithoutContentTransformations() : ctx);
                    strDataCmp = SprEngine.CompileInternal(strData, ctxData,
                                                           uRecursionLevel + 1);
                }

                string strRep = null;
                if (i == 0)
                {
                    strRep = strDataCmp;
                }
                // UrlUtil supports prefixes like cmd://
                else if (i == 1)
                {
                    strRep = UrlUtil.RemoveScheme(strDataCmp);
                }
                else if (i == 2)
                {
                    strRep = UrlUtil.GetScheme(strDataCmp);
                }
                else
                {
                    try
                    {
                        if (uri == null)
                        {
                            uri = new Uri(strDataCmp);
                        }

                        int t;
                        switch (i)
                        {
                        // case 2: strRep = uri.Scheme; break; // No cmd:// support
                        case 3: strRep = uri.Host; break;

                        case 4:
                            strRep = uri.Port.ToString(
                                NumberFormatInfo.InvariantInfo);
                            break;

                        case 5: strRep = uri.AbsolutePath; break;

                        case 6: strRep = uri.Query; break;

                        case 7: strRep = uri.UserInfo; break;

                        case 8:
                            strRep = uri.UserInfo;
                            t      = strRep.IndexOf(':');
                            if (t >= 0)
                            {
                                strRep = strRep.Substring(0, t);
                            }
                            break;

                        case 9:
                            strRep = uri.UserInfo;
                            t      = strRep.IndexOf(':');
                            if (t < 0)
                            {
                                strRep = string.Empty;
                            }
                            else
                            {
                                strRep = strRep.Substring(t + 1);
                            }
                            break;

                        default: Debug.Assert(false); break;
                        }
                    }
                    catch (Exception) { }                    // Invalid URI
                }
                if (strRep == null)
                {
                    strRep = string.Empty;                                // No assert
                }
                str = StrUtil.ReplaceCaseInsensitive(str, strPlh, strRep);
            }

            return(str);
        }
コード例 #16
0
        private static string ShowCharPickDlg(string strWord, uint uCharCount,
            bool? bInitHide, SprContext ctx, uint uRecursionLevel)
        {
            string strPick = SprEngine.CompileInternal(strWord,
                ctx.WithoutContentTransformations(), uRecursionLevel + 1);

            // No need to show the dialog when there's nothing to pick from
            // (this also prevents the dialog from showing up MaxRecursionDepth
            // times in case of a cyclic {PICKCHARS})
            if(string.IsNullOrEmpty(strPick)) return string.Empty;

            CharPickerForm cpf = new CharPickerForm();
            cpf.InitEx(new ProtectedString(false, strPick), true, true,
                uCharCount, bInitHide);

            string strResult = string.Empty;
            if(cpf.ShowDialog() == DialogResult.OK)
                strResult = cpf.SelectedCharacters.ReadString();

            UIUtil.DestroyForm(cpf);
            return strResult; // Don't transform here
        }
コード例 #17
0
ファイル: SprEngine.PickChars.cs プロジェクト: Stoom/KeePass
        private static string ShowCharPickDlg(string strWord, uint uCharCount,
			bool? bInitHide, SprContext ctx, uint uRecursionLevel)
        {
            string strPick = SprEngine.CompileInternal(strWord,
                ctx.WithoutContentTransformations(), uRecursionLevel + 1);

            // No need to show the dialog when there's nothing to pick from
            // (this also prevents the dialog from showing up MaxRecursionDepth
            // times in case of a cyclic {PICKCHARS})
            if(string.IsNullOrEmpty(strPick)) return string.Empty;

            ProtectedString psWord = new ProtectedString(false, strPick);
            string strPicked = CharPickerForm.ShowAndRestore(psWord,
                true, true, uCharCount, bInitHide);
            return (strPicked ?? string.Empty); // Don't transform here
        }