Update Lib to version 2.44

Update nuget packages
This commit is contained in:
Geoffroy BONNEVILLE
2020-03-16 15:28:05 +01:00
parent 3a85b60e58
commit b8240d482f
108 changed files with 1102 additions and 595 deletions

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2019 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2019 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2019 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -597,20 +597,34 @@ namespace ModernKeePassLib.Utility
if(sSource == null) throw new ArgumentNullException("sSource");
if(sTarget == null) throw new ArgumentNullException("sTarget");
const int nBufSize = 4096;
byte[] pbBuf = new byte[nBufSize];
const int cbBuf = 4096;
byte[] pbBuf = new byte[cbBuf];
while(true)
{
int nRead = sSource.Read(pbBuf, 0, nBufSize);
if(nRead == 0) break;
int cbRead = sSource.Read(pbBuf, 0, cbBuf);
if(cbRead == 0) break;
sTarget.Write(pbBuf, 0, nRead);
sTarget.Write(pbBuf, 0, cbRead);
}
// Do not close any of the streams
}
public static byte[] Read(Stream s)
{
if(s == null) throw new ArgumentNullException("s");
byte[] pb;
using(MemoryStream ms = new MemoryStream())
{
MemUtil.CopyStream(s, ms);
pb = ms.ToArray();
}
return pb;
}
public static byte[] Read(Stream s, int nCount)
{
if(s == null) throw new ArgumentNullException("s");

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2019 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2019 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -141,6 +141,12 @@ namespace ModernKeePassLib.Utility
// 100001:
// Control locations/sizes are invalid/unexpected.
// [NoRef]
// 100002:
// TextChanged event isn't raised when the formatting changes.
// [NoRef]
// 190417:
// Mono's Process.Start method replaces '\\' by '/'.
// https://github.com/mono/mono/blob/master/mono/metadata/w32process-unix.c
// 373134:
// Control.InvokeRequired doesn't always return the correct value.
// https://bugzilla.novell.com/show_bug.cgi?id=373134

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2019 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -398,12 +398,6 @@ namespace ModernKeePassLib.Utility
public static void SplitCommandLine(string strCmdLine, out string strApp,
out string strArgs)
{
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"); }
@@ -435,7 +429,7 @@ namespace ModernKeePassLib.Utility
if(strApp == null) { Debug.Assert(false); strApp = string.Empty; }
if(strArgs == null) strArgs = string.Empty;
if(bDecodeAppToPath) strApp = NativeLib.DecodeArgsToPath(strApp);
strApp = NativeLib.DecodeArgsToData(strApp);
}
// /// <summary>
@@ -538,7 +532,7 @@ namespace ModernKeePassLib.Utility
if(!string.IsNullOrEmpty(excp.StackTrace))
strText += excp.StackTrace + MessageService.NewLine;
#if !KeePassLibSD
#if !ModernKeePassLib && !KeePassRT
#if !ModernKeePassLib
if(excp.TargetSite != null)
strText += excp.TargetSite.ToString() + MessageService.NewLine;
#endif
@@ -564,7 +558,7 @@ namespace ModernKeePassLib.Utility
if(!string.IsNullOrEmpty(excp.InnerException.StackTrace))
strText += excp.InnerException.StackTrace + MessageService.NewLine;
#if !KeePassLibSD
#if !ModernKeePassLib && !KeePassRT
#if !ModernKeePassLib
if(excp.InnerException.TargetSite != null)
strText += excp.InnerException.TargetSite.ToString();
#endif
@@ -966,10 +960,10 @@ namespace ModernKeePassLib.Utility
for(char ch = 'A'; ch <= 'Z'; ++ch)
{
string strEnhAcc = @"(&" + ch.ToString() + @")";
string strEnhAcc = @"(&" + ch.ToString() + ")";
if(str.IndexOf(strEnhAcc) >= 0)
{
str = str.Replace(@" " + strEnhAcc, string.Empty);
str = str.Replace(" " + strEnhAcc, string.Empty);
str = str.Replace(strEnhAcc, string.Empty);
}
}
@@ -1382,7 +1376,7 @@ namespace ModernKeePassLib.Utility
byte[] pbEnc = CryptoUtil.ProtectData(pbPlain, m_pbOptEnt,
DataProtectionScope.CurrentUser);
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassRT)
#if (!ModernKeePassLib && !KeePassLibSD)
return Convert.ToBase64String(pbEnc, Base64FormattingOptions.None);
#else
return Convert.ToBase64String(pbEnc);
@@ -1495,7 +1489,7 @@ namespace ModernKeePassLib.Utility
Array.Reverse(pb);
for(int i = 0; i < pb.Length; ++i) pb[i] = (byte)(pb[i] ^ 0x65);
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassRT)
#if (!ModernKeePassLib && !KeePassLibSD)
return Convert.ToBase64String(pb, Base64FormattingOptions.None);
#else
return Convert.ToBase64String(pb);
@@ -1655,7 +1649,7 @@ namespace ModernKeePassLib.Utility
if(strMediaType == null) strMediaType = "application/octet-stream";
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassRT)
#if (!ModernKeePassLib && !KeePassLibSD)
return ("data:" + strMediaType + ";base64," + Convert.ToBase64String(
pbData, Base64FormattingOptions.None));
#else

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2019 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2019 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2019 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -275,21 +275,30 @@ namespace ModernKeePassLib.Utility
public static string FileUrlToPath(string strUrl)
{
Debug.Assert(strUrl != null);
if(strUrl == null) throw new ArgumentNullException("strUrl");
if(strUrl == null) { Debug.Assert(false); throw new ArgumentNullException("strUrl"); }
if(strUrl.Length == 0) { Debug.Assert(false); return string.Empty; }
string str = strUrl;
if(str.StartsWith("file:///", StrUtil.CaseIgnoreCmp))
str = str.Substring(8, str.Length - 8);
if(!strUrl.StartsWith(Uri.UriSchemeFile + ":", StrUtil.CaseIgnoreCmp))
{
Debug.Assert(false);
return strUrl;
}
str = str.Replace('/', UrlUtil.LocalDirSepChar);
try
{
Uri uri = new Uri(strUrl);
string str = uri.LocalPath;
if(!string.IsNullOrEmpty(str)) return str;
}
catch(Exception) { Debug.Assert(false); }
return str;
Debug.Assert(false);
return strUrl;
}
public static bool UnhideFile(string strFile)
{
#if (ModernKeePassLib || KeePassLibSD || KeePassRT)
#if (ModernKeePassLib || KeePassLibSD)
return false;
#else
if(strFile == null) throw new ArgumentNullException("strFile");
@@ -309,7 +318,7 @@ namespace ModernKeePassLib.Utility
public static bool HideFile(string strFile, bool bHide)
{
#if (ModernKeePassLib || KeePassLibSD || KeePassRT)
#if (ModernKeePassLib || KeePassLibSD)
return false;
#else
if(strFile == null) throw new ArgumentNullException("strFile");
@@ -606,7 +615,7 @@ namespace ModernKeePassLib.Utility
}
/// <summary>
/// Get the host component of an URL.
/// Get the host component of a URL.
/// This method is faster and more fault-tolerant than creating
/// an <code>Uri</code> object and querying its <code>Host</code>
/// property.
@@ -776,21 +785,32 @@ namespace ModernKeePassLib.Utility
/// Expand shell variables in a string.
/// <paramref name="vParams" />[0] is the value of <c>%1</c>, etc.
/// </summary>
public static string ExpandShellVariables(string strText, string[] vParams)
internal static string ExpandShellVariables(string strText, string[] vParams,
bool bEncParamsToArgs)
{
if(strText == null) { Debug.Assert(false); return string.Empty; }
if(vParams == null) { Debug.Assert(false); vParams = new string[0]; }
string[] v = vParams;
if(v == null) { Debug.Assert(false); v = new string[0]; }
if(bEncParamsToArgs)
{
for(int i = 0; i < v.Length; ++i)
v[i] = NativeLib.EncodeDataToArgs(v[i] ?? string.Empty);
}
string str = strText;
NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;
string strPctPlh = Guid.NewGuid().ToString();
str = str.Replace("%%", strPctPlh);
for(int i = 0; i <= 9; ++i)
{
string strPlh = "%" + i.ToString(nfi);
string strValue = string.Empty;
if((i > 0) && ((i - 1) < vParams.Length))
strValue = (vParams[i - 1] ?? string.Empty);
if((i > 0) && ((i - 1) < v.Length))
strValue = (v[i - 1] ?? string.Empty);
str = str.Replace(strPlh, strValue);
@@ -806,7 +826,7 @@ namespace ModernKeePassLib.Utility
if(str.IndexOf("%*") >= 0)
{
StringBuilder sb = new StringBuilder();
foreach(string strValue in vParams)
foreach(string strValue in v)
{
if(!string.IsNullOrEmpty(strValue))
{
@@ -818,6 +838,7 @@ namespace ModernKeePassLib.Utility
str = str.Replace("%*", sb.ToString());
}
str = str.Replace(strPctPlh, "%");
return str;
}
@@ -846,5 +867,21 @@ namespace ModernKeePassLib.Utility
}
return str;
}
internal static string GetCanonicalUri(string strUri)
{
if(string.IsNullOrEmpty(strUri)) { Debug.Assert(false); return strUri; }
try
{
Uri uri = new Uri(strUri);
if(uri.IsAbsoluteUri) return uri.AbsoluteUri;
else { Debug.Assert(false); }
}
catch(Exception) { Debug.Assert(false); }
return strUri;
}
}
}

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2019 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -116,5 +116,21 @@ namespace ModernKeePassLib.Utility
return t;
}
#if DEBUG
internal static void ValidateXml(string strXml, bool bReplaceStdEntities)
{
if(strXml == null) throw new ArgumentNullException("strXml");
if(strXml.Length == 0) { Debug.Assert(false); return; }
string str = strXml;
if(bReplaceStdEntities)
str = str.Replace("&nbsp;", "&#160;");
XmlDocument d = new XmlDocument();
d.LoadXml(str);
}
#endif
}
}