mirror of
https://github.com/wismna/ModernKeePassLib.git
synced 2025-10-03 15:40:20 -04:00
Update to version 2.42.1
Some changes Removed FutureAccesList code as it works only with UWP
This commit is contained in:
@@ -264,8 +264,7 @@ namespace ModernKeePassLib.Utility
|
||||
[MethodImpl(MioNoOptimize)]
|
||||
public static void ZeroByteArray(byte[] pbArray)
|
||||
{
|
||||
Debug.Assert(pbArray != null);
|
||||
if(pbArray == null) throw new ArgumentNullException("pbArray");
|
||||
if(pbArray == null) { Debug.Assert(false); return; }
|
||||
|
||||
Array.Clear(pbArray, 0, pbArray.Length);
|
||||
}
|
||||
@@ -277,7 +276,7 @@ namespace ModernKeePassLib.Utility
|
||||
[MethodImpl(MioNoOptimize)]
|
||||
public static void ZeroArray<T>(T[] v)
|
||||
{
|
||||
if(v == null) { Debug.Assert(false); throw new ArgumentNullException("v"); }
|
||||
if(v == null) { Debug.Assert(false); return; }
|
||||
|
||||
Array.Clear(v, 0, v.Length);
|
||||
}
|
||||
|
@@ -116,9 +116,6 @@ namespace ModernKeePassLib.Utility
|
||||
// 1760:
|
||||
// Input focus is not restored when activating a form.
|
||||
// https://sourceforge.net/p/keepass/bugs/1760/
|
||||
// 2139:
|
||||
// Shortcut keys are ignored.
|
||||
// https://sourceforge.net/p/keepass/feature-requests/2139/
|
||||
// 2140:
|
||||
// Explicit control focusing is ignored.
|
||||
// https://sourceforge.net/p/keepass/feature-requests/2140/
|
||||
|
@@ -24,7 +24,6 @@ using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
#if !KeePassUAP
|
||||
using System.Drawing;
|
||||
@@ -44,45 +43,41 @@ namespace ModernKeePassLib.Utility
|
||||
/// </summary>
|
||||
public sealed class CharStream
|
||||
{
|
||||
private string m_strString = string.Empty;
|
||||
private int m_nPos = 0;
|
||||
private readonly string m_str;
|
||||
private int m_iPos = 0;
|
||||
|
||||
public long Position
|
||||
{
|
||||
get { return m_iPos; }
|
||||
set
|
||||
{
|
||||
if((value < 0) || (value > int.MaxValue))
|
||||
throw new ArgumentOutOfRangeException("value");
|
||||
m_iPos = (int)value;
|
||||
}
|
||||
}
|
||||
|
||||
public CharStream(string str)
|
||||
{
|
||||
Debug.Assert(str != null);
|
||||
if(str == null) throw new ArgumentNullException("str");
|
||||
if(str == null) { Debug.Assert(false); throw new ArgumentNullException("str"); }
|
||||
|
||||
m_strString = str;
|
||||
}
|
||||
|
||||
public void Seek(SeekOrigin org, int nSeek)
|
||||
{
|
||||
if(org == SeekOrigin.Begin)
|
||||
m_nPos = nSeek;
|
||||
else if(org == SeekOrigin.Current)
|
||||
m_nPos += nSeek;
|
||||
else if(org == SeekOrigin.End)
|
||||
m_nPos = m_strString.Length + nSeek;
|
||||
m_str = str;
|
||||
}
|
||||
|
||||
public char ReadChar()
|
||||
{
|
||||
if(m_nPos < 0) return char.MinValue;
|
||||
if(m_nPos >= m_strString.Length) return char.MinValue;
|
||||
if(m_iPos >= m_str.Length) return char.MinValue;
|
||||
|
||||
char chRet = m_strString[m_nPos];
|
||||
++m_nPos;
|
||||
return chRet;
|
||||
return m_str[m_iPos++];
|
||||
}
|
||||
|
||||
public char ReadChar(bool bSkipWhiteSpace)
|
||||
{
|
||||
if(bSkipWhiteSpace == false) return ReadChar();
|
||||
if(!bSkipWhiteSpace) return ReadChar();
|
||||
|
||||
while(true)
|
||||
{
|
||||
char ch = ReadChar();
|
||||
|
||||
if((ch != ' ') && (ch != '\t') && (ch != '\r') && (ch != '\n'))
|
||||
return ch;
|
||||
}
|
||||
@@ -90,29 +85,25 @@ namespace ModernKeePassLib.Utility
|
||||
|
||||
public char PeekChar()
|
||||
{
|
||||
if(m_nPos < 0) return char.MinValue;
|
||||
if(m_nPos >= m_strString.Length) return char.MinValue;
|
||||
if(m_iPos >= m_str.Length) return char.MinValue;
|
||||
|
||||
return m_strString[m_nPos];
|
||||
return m_str[m_iPos];
|
||||
}
|
||||
|
||||
public char PeekChar(bool bSkipWhiteSpace)
|
||||
{
|
||||
if(bSkipWhiteSpace == false) return PeekChar();
|
||||
if(!bSkipWhiteSpace) return PeekChar();
|
||||
|
||||
int iIndex = m_nPos;
|
||||
while(true)
|
||||
int i = m_iPos;
|
||||
while(i < m_str.Length)
|
||||
{
|
||||
if(iIndex < 0) return char.MinValue;
|
||||
if(iIndex >= m_strString.Length) return char.MinValue;
|
||||
|
||||
char ch = m_strString[iIndex];
|
||||
|
||||
char ch = m_str[i];
|
||||
if((ch != ' ') && (ch != '\t') && (ch != '\r') && (ch != '\n'))
|
||||
return ch;
|
||||
|
||||
++iIndex;
|
||||
++i;
|
||||
}
|
||||
|
||||
return char.MinValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,44 +396,46 @@ namespace ModernKeePassLib.Utility
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Split up a command line into application and argument.
|
||||
/// </summary>
|
||||
/// <param name="strCmdLine">Command line to split.</param>
|
||||
/// <param name="strApp">Application path.</param>
|
||||
/// <param name="strArgs">Arguments.</param>
|
||||
public static void SplitCommandLine(string strCmdLine, out string strApp, out string strArgs)
|
||||
public static void SplitCommandLine(string strCmdLine, out string strApp,
|
||||
out string strArgs)
|
||||
{
|
||||
Debug.Assert(strCmdLine != null); if(strCmdLine == null) throw new ArgumentNullException("strCmdLine");
|
||||
SplitCommandLine(strCmdLine, out strApp, out strArgs, true);
|
||||
}
|
||||
|
||||
internal static void SplitCommandLine(string strCmdLine, out string strApp,
|
||||
out string strArgs, bool bDecodeAppToPath)
|
||||
{
|
||||
if(strCmdLine == null) { Debug.Assert(false); throw new ArgumentNullException("strCmdLine"); }
|
||||
|
||||
string str = strCmdLine.Trim();
|
||||
|
||||
strApp = null; strArgs = null;
|
||||
strApp = null;
|
||||
strArgs = null;
|
||||
|
||||
if(str.StartsWith("\""))
|
||||
{
|
||||
int nSecond = str.IndexOf('\"', 1);
|
||||
if(nSecond >= 1)
|
||||
int iSecond = UrlUtil.IndexOfSecondEnclQuote(str);
|
||||
if(iSecond >= 1)
|
||||
{
|
||||
strApp = str.Substring(1, nSecond - 1).Trim();
|
||||
strArgs = str.Remove(0, nSecond + 1).Trim();
|
||||
strApp = str.Substring(1, iSecond - 1).Trim();
|
||||
strArgs = str.Remove(0, iSecond + 1).Trim();
|
||||
}
|
||||
}
|
||||
|
||||
if(strApp == null)
|
||||
{
|
||||
int nSpace = str.IndexOf(' ');
|
||||
|
||||
if(nSpace >= 0)
|
||||
int iSpace = str.IndexOf(' ');
|
||||
if(iSpace >= 0)
|
||||
{
|
||||
strApp = str.Substring(0, nSpace);
|
||||
strArgs = str.Remove(0, nSpace).Trim();
|
||||
strApp = str.Substring(0, iSpace).Trim();
|
||||
strArgs = str.Remove(0, iSpace + 1).Trim();
|
||||
}
|
||||
else strApp = strCmdLine;
|
||||
else strApp = str;
|
||||
}
|
||||
|
||||
if(strApp == null) strApp = string.Empty;
|
||||
if(strApp == null) { Debug.Assert(false); strApp = string.Empty; }
|
||||
if(strArgs == null) strArgs = string.Empty;
|
||||
|
||||
if(bDecodeAppToPath) strApp = NativeLib.DecodeArgsToPath(strApp);
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
@@ -1289,7 +1282,7 @@ namespace ModernKeePassLib.Utility
|
||||
if(uBytes <= uGB) return (((uBytes - 1UL) / uMB) + 1UL).ToString() + " MB";
|
||||
if(uBytes <= uTB) return (((uBytes - 1UL) / uGB) + 1UL).ToString() + " GB";
|
||||
|
||||
return (((uBytes - 1UL)/ uTB) + 1UL).ToString() + " TB";
|
||||
return (((uBytes - 1UL) / uTB) + 1UL).ToString() + " TB";
|
||||
}
|
||||
|
||||
public static string FormatDataSizeKB(ulong uBytes)
|
||||
|
@@ -23,6 +23,7 @@ using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
#if ModernKeePassLib
|
||||
using Windows.Storage;
|
||||
@@ -38,12 +39,8 @@ namespace ModernKeePassLib.Utility
|
||||
/// </summary>
|
||||
public static class UrlUtil
|
||||
{
|
||||
private static readonly char[] m_vDirSeps = new char[] {
|
||||
'\\', '/', UrlUtil.LocalDirSepChar };
|
||||
#if !ModernKeePassLib
|
||||
private static readonly char[] m_vPathTrimCharsWs = new char[] {
|
||||
private static readonly char[] g_vPathTrimCharsWs = new char[] {
|
||||
'\"', ' ', '\t', '\r', '\n' };
|
||||
#endif
|
||||
|
||||
public static char LocalDirSepChar
|
||||
{
|
||||
@@ -57,6 +54,32 @@ namespace ModernKeePassLib.Utility
|
||||
#endif
|
||||
}
|
||||
|
||||
private static char[] g_vDirSepChars = null;
|
||||
private static char[] DirSepChars
|
||||
{
|
||||
get
|
||||
{
|
||||
if(g_vDirSepChars == null)
|
||||
{
|
||||
List<char> l = new List<char>();
|
||||
l.Add('/'); // For URLs, also on Windows
|
||||
|
||||
// On Unix-like systems, '\\' is not a separator
|
||||
if(!NativeLib.IsUnix()) l.Add('\\');
|
||||
|
||||
if(!l.Contains(UrlUtil.LocalDirSepChar))
|
||||
{
|
||||
Debug.Assert(false);
|
||||
l.Add(UrlUtil.LocalDirSepChar);
|
||||
}
|
||||
|
||||
g_vDirSepChars = l.ToArray();
|
||||
}
|
||||
|
||||
return g_vDirSepChars;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the directory (path) of a file name. The returned string may be
|
||||
/// terminated by a directory separator character. Example:
|
||||
@@ -79,7 +102,7 @@ namespace ModernKeePassLib.Utility
|
||||
Debug.Assert(strFile != null);
|
||||
if(strFile == null) throw new ArgumentNullException("strFile");
|
||||
|
||||
int nLastSep = strFile.LastIndexOfAny(m_vDirSeps);
|
||||
int nLastSep = strFile.LastIndexOfAny(UrlUtil.DirSepChars);
|
||||
if(nLastSep < 0) return string.Empty; // No directory
|
||||
|
||||
if(bEnsureValidDirSpec && (nLastSep == 2) && (strFile[1] == ':') &&
|
||||
@@ -103,7 +126,7 @@ namespace ModernKeePassLib.Utility
|
||||
{
|
||||
Debug.Assert(strPath != null); if(strPath == null) throw new ArgumentNullException("strPath");
|
||||
|
||||
int nLastSep = strPath.LastIndexOfAny(m_vDirSeps);
|
||||
int nLastSep = strPath.LastIndexOfAny(UrlUtil.DirSepChars);
|
||||
|
||||
if(nLastSep < 0) return strPath;
|
||||
if(nLastSep >= (strPath.Length - 1)) return string.Empty;
|
||||
@@ -120,7 +143,7 @@ namespace ModernKeePassLib.Utility
|
||||
{
|
||||
Debug.Assert(strPath != null); if(strPath == null) throw new ArgumentNullException("strPath");
|
||||
|
||||
int nLastDirSep = strPath.LastIndexOfAny(m_vDirSeps);
|
||||
int nLastDirSep = strPath.LastIndexOfAny(UrlUtil.DirSepChars);
|
||||
int nLastExtDot = strPath.LastIndexOf('.');
|
||||
|
||||
if(nLastExtDot <= nLastDirSep) return strPath;
|
||||
@@ -137,7 +160,7 @@ namespace ModernKeePassLib.Utility
|
||||
{
|
||||
Debug.Assert(strPath != null); if(strPath == null) throw new ArgumentNullException("strPath");
|
||||
|
||||
int nLastDirSep = strPath.LastIndexOfAny(m_vDirSeps);
|
||||
int nLastDirSep = strPath.LastIndexOfAny(UrlUtil.DirSepChars);
|
||||
int nLastExtDot = strPath.LastIndexOf('.');
|
||||
|
||||
if(nLastExtDot <= nLastDirSep) return string.Empty;
|
||||
@@ -162,11 +185,8 @@ namespace ModernKeePassLib.Utility
|
||||
if(nLength <= 0) return string.Empty;
|
||||
|
||||
char chLast = strPath[nLength - 1];
|
||||
|
||||
for(int i = 0; i < m_vDirSeps.Length; ++i)
|
||||
{
|
||||
if(chLast == m_vDirSeps[i]) return strPath;
|
||||
}
|
||||
if(Array.IndexOf<char>(UrlUtil.DirSepChars, chLast) >= 0)
|
||||
return strPath;
|
||||
|
||||
if(bUrl) return (strPath + '/');
|
||||
return (strPath + UrlUtil.LocalDirSepChar);
|
||||
@@ -230,21 +250,35 @@ namespace ModernKeePassLib.Utility
|
||||
return false;
|
||||
} */
|
||||
|
||||
internal static int IndexOfSecondEnclQuote(string str)
|
||||
{
|
||||
if(str == null) { Debug.Assert(false); return -1; }
|
||||
if(str.Length <= 1) return -1;
|
||||
if(str[0] != '\"') { Debug.Assert(false); return -1; }
|
||||
|
||||
if(NativeLib.IsUnix())
|
||||
{
|
||||
// Find non-escaped quote
|
||||
string strFlt = str.Replace("\\\\", new string(
|
||||
StrUtil.GetUnusedChar(str + "\\\""), 2)); // Same length
|
||||
Match m = Regex.Match(strFlt, "[^\\\\]\\u0022");
|
||||
int i = (((m != null) && m.Success) ? m.Index : -1);
|
||||
return ((i >= 0) ? (i + 1) : -1); // Index of quote
|
||||
}
|
||||
|
||||
// Windows does not allow quotes in folder/file names
|
||||
return str.IndexOf('\"', 1);
|
||||
}
|
||||
|
||||
public static string GetQuotedAppPath(string strPath)
|
||||
{
|
||||
if(strPath == null) { Debug.Assert(false); return string.Empty; }
|
||||
|
||||
// int nFirst = strPath.IndexOf('\"');
|
||||
// int nSecond = strPath.IndexOf('\"', nFirst + 1);
|
||||
// if((nFirst >= 0) && (nSecond >= 0))
|
||||
// return strPath.Substring(nFirst + 1, nSecond - nFirst - 1);
|
||||
// return strPath;
|
||||
|
||||
string str = strPath.Trim();
|
||||
if(str.Length <= 1) return str;
|
||||
if(str[0] != '\"') return str;
|
||||
|
||||
int iSecond = str.IndexOf('\"', 1);
|
||||
int iSecond = IndexOfSecondEnclQuote(str);
|
||||
if(iSecond <= 0) return str;
|
||||
|
||||
return str.Substring(1, iSecond - 1);
|
||||
@@ -256,7 +290,7 @@ namespace ModernKeePassLib.Utility
|
||||
if(strUrl == null) throw new ArgumentNullException("strUrl");
|
||||
|
||||
string str = strUrl;
|
||||
if(str.StartsWith(@"file:///", StrUtil.CaseIgnoreCmp))
|
||||
if(str.StartsWith("file:///", StrUtil.CaseIgnoreCmp))
|
||||
str = str.Substring(8, str.Length - 8);
|
||||
|
||||
str = str.Replace('/', UrlUtil.LocalDirSepChar);
|
||||
@@ -338,8 +372,8 @@ namespace ModernKeePassLib.Utility
|
||||
|
||||
string strBase = GetShortestAbsolutePath(strBaseFile);
|
||||
string strTarget = GetShortestAbsolutePath(strTargetFile);
|
||||
string[] vBase = strBase.Split(m_vDirSeps);
|
||||
string[] vTarget = strTarget.Split(m_vDirSeps);
|
||||
string[] vBase = strBase.Split(UrlUtil.DirSepChars);
|
||||
string[] vTarget = strTarget.Split(UrlUtil.DirSepChars);
|
||||
|
||||
int i = 0;
|
||||
while((i < (vBase.Length - 1)) && (i < (vTarget.Length - 1)) &&
|
||||
@@ -416,13 +450,14 @@ namespace ModernKeePassLib.Utility
|
||||
if(IsUncPath(strPath))
|
||||
{
|
||||
char chSep = strPath[0];
|
||||
Debug.Assert(Array.IndexOf<char>(m_vDirSeps, chSep) >= 0);
|
||||
char[] vSep = ((chSep == '/') ? (new char[] { '/' }) :
|
||||
(new char[] { '\\', '/' }));
|
||||
|
||||
List<string> l = new List<string>();
|
||||
#if !KeePassLibSD
|
||||
string[] v = strPath.Split(m_vDirSeps, StringSplitOptions.None);
|
||||
string[] v = strPath.Split(vSep, StringSplitOptions.None);
|
||||
#else
|
||||
string[] v = strPath.Split(m_vDirSeps);
|
||||
string[] v = strPath.Split(vSep);
|
||||
#endif
|
||||
Debug.Assert((v.Length >= 3) && (v[0].Length == 0) &&
|
||||
(v[1].Length == 0));
|
||||
@@ -463,8 +498,8 @@ namespace ModernKeePassLib.Utility
|
||||
}
|
||||
catch(Exception) { Debug.Assert(false); return strPath; }
|
||||
|
||||
Debug.Assert(str.IndexOf("\\..\\") < 0);
|
||||
foreach(char ch in m_vDirSeps)
|
||||
Debug.Assert((str.IndexOf("\\..\\") < 0) || NativeLib.IsUnix());
|
||||
foreach(char ch in UrlUtil.DirSepChars)
|
||||
{
|
||||
string strSep = new string(ch, 1);
|
||||
str = str.Replace(strSep + "." + strSep, strSep);
|
||||
@@ -494,24 +529,30 @@ namespace ModernKeePassLib.Utility
|
||||
return nLength;
|
||||
}
|
||||
|
||||
internal static string GetScheme(string strUrl)
|
||||
{
|
||||
if(string.IsNullOrEmpty(strUrl)) return string.Empty;
|
||||
|
||||
int i = strUrl.IndexOf(':');
|
||||
if(i > 0) return strUrl.Substring(0, i);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static string RemoveScheme(string strUrl)
|
||||
{
|
||||
if(string.IsNullOrEmpty(strUrl)) return string.Empty;
|
||||
|
||||
int nNetScheme = strUrl.IndexOf(@"://", StrUtil.CaseIgnoreCmp);
|
||||
int nShScheme = strUrl.IndexOf(@":/", StrUtil.CaseIgnoreCmp);
|
||||
int nSmpScheme = strUrl.IndexOf(@":", StrUtil.CaseIgnoreCmp);
|
||||
int i = strUrl.IndexOf(':');
|
||||
if(i < 0) return strUrl; // No scheme to remove
|
||||
++i;
|
||||
|
||||
if((nNetScheme < 0) && (nShScheme < 0) && (nSmpScheme < 0))
|
||||
return strUrl; // No scheme
|
||||
// A single '/' indicates a path (absolute) and should not be removed
|
||||
if(((i + 1) < strUrl.Length) && (strUrl[i] == '/') &&
|
||||
(strUrl[i + 1] == '/'))
|
||||
i += 2; // Skip authority prefix
|
||||
|
||||
int nMin = Math.Min(Math.Min((nNetScheme >= 0) ? nNetScheme : int.MaxValue,
|
||||
(nShScheme >= 0) ? nShScheme : int.MaxValue),
|
||||
(nSmpScheme >= 0) ? nSmpScheme : int.MaxValue);
|
||||
|
||||
if(nMin == nNetScheme) return strUrl.Substring(nMin + 3);
|
||||
if(nMin == nShScheme) return strUrl.Substring(nMin + 2);
|
||||
return strUrl.Substring(nMin + 1);
|
||||
return strUrl.Substring(i);
|
||||
}
|
||||
|
||||
public static string ConvertSeparators(string strPath)
|
||||
@@ -538,22 +579,50 @@ namespace ModernKeePassLib.Utility
|
||||
|
||||
public static string FilterFileName(string strName)
|
||||
{
|
||||
if(strName == null) { Debug.Assert(false); return string.Empty; }
|
||||
if(string.IsNullOrEmpty(strName)) { Debug.Assert(false); return string.Empty; }
|
||||
|
||||
string str = strName;
|
||||
// https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file
|
||||
|
||||
str = str.Replace('/', '-');
|
||||
str = str.Replace('\\', '-');
|
||||
str = str.Replace(":", string.Empty);
|
||||
str = str.Replace("*", string.Empty);
|
||||
str = str.Replace("?", string.Empty);
|
||||
str = str.Replace("\"", string.Empty);
|
||||
str = str.Replace(@"'", string.Empty);
|
||||
str = str.Replace('<', '(');
|
||||
str = str.Replace('>', ')');
|
||||
str = str.Replace('|', '-');
|
||||
StringBuilder sb = new StringBuilder(strName.Length);
|
||||
foreach(char ch in strName)
|
||||
{
|
||||
if(ch < '\u0020') continue;
|
||||
|
||||
return str;
|
||||
switch(ch)
|
||||
{
|
||||
case '\"':
|
||||
case '*':
|
||||
case ':':
|
||||
case '?':
|
||||
break;
|
||||
|
||||
case '/':
|
||||
case '\\':
|
||||
case '|':
|
||||
sb.Append('-');
|
||||
break;
|
||||
|
||||
case '<':
|
||||
sb.Append('(');
|
||||
break;
|
||||
|
||||
case '>':
|
||||
sb.Append(')');
|
||||
break;
|
||||
|
||||
default: sb.Append(ch); break;
|
||||
}
|
||||
}
|
||||
|
||||
// Trim trailing spaces and periods
|
||||
for(int i = sb.Length - 1; i >= 0; --i)
|
||||
{
|
||||
char ch = sb[i];
|
||||
if((ch == ' ') || (ch == '.')) sb.Remove(i, 1);
|
||||
else break;
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -672,7 +741,7 @@ namespace ModernKeePassLib.Utility
|
||||
foreach(string strPathRaw in v)
|
||||
{
|
||||
if(strPathRaw == null) { Debug.Assert(false); continue; }
|
||||
string strPath = strPathRaw.Trim(m_vPathTrimCharsWs);
|
||||
string strPath = strPathRaw.Trim(g_vPathTrimCharsWs);
|
||||
if(strPath.Length == 0) { Debug.Assert(false); continue; }
|
||||
Debug.Assert(strPath == strPathRaw);
|
||||
|
||||
@@ -709,7 +778,7 @@ namespace ModernKeePassLib.Utility
|
||||
if(fi == null) { Debug.Assert(false); continue; }
|
||||
string strPathRaw = fi.FullName;
|
||||
if(strPathRaw == null) { Debug.Assert(false); continue; }
|
||||
string strPath = strPathRaw.Trim(m_vPathTrimCharsWs);
|
||||
string strPath = strPathRaw.Trim(g_vPathTrimCharsWs);
|
||||
if(strPath.Length == 0) { Debug.Assert(false); continue; }
|
||||
Debug.Assert(strPath == strPathRaw);
|
||||
|
||||
@@ -783,5 +852,19 @@ namespace ModernKeePassLib.Utility
|
||||
char ch = char.ToUpperInvariant(strPath[0]);
|
||||
return (((ch >= 'A') && (ch <= 'Z')) ? ch : '\0');
|
||||
}
|
||||
|
||||
internal static string GetSafeFileName(string strName)
|
||||
{
|
||||
Debug.Assert(!string.IsNullOrEmpty(strName));
|
||||
|
||||
string str = FilterFileName(GetFileName(strName ?? string.Empty));
|
||||
|
||||
if(string.IsNullOrEmpty(str))
|
||||
{
|
||||
Debug.Assert(false);
|
||||
return "File.dat";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@ namespace ModernKeePassLib.Utility
|
||||
xrs.IgnoreProcessingInstructions = true;
|
||||
xrs.IgnoreWhitespace = true;
|
||||
|
||||
#if KeePassUAP
|
||||
#if KeePassUAP || ModernKeePassLib
|
||||
xrs.DtdProcessing = DtdProcessing.Prohibit;
|
||||
#else
|
||||
// Also see PrepMonoDev.sh script
|
||||
|
Reference in New Issue
Block a user