KeepassLib version update to 2.38

This commit is contained in:
BONNEVILLE Geoffroy
2018-03-09 17:49:47 +01:00
parent fc25d7ea93
commit 49637fcc3b
100 changed files with 556 additions and 278 deletions

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2017 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2018 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-2017 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2018 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-2017 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2018 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
@@ -37,7 +37,10 @@ namespace ModernKeePassLib.Utility
/// </summary>
public static class MemUtil
{
public static readonly byte[] EmptyByteArray = new byte[0];
internal static readonly byte[] EmptyByteArray = new byte[0];
internal static readonly ArrayHelperEx<char> ArrayHelperExOfChar =
new ArrayHelperEx<char>();
private static readonly uint[] m_vSBox = new uint[256] {
0xCD2FACB3, 0xE78A7F5C, 0x6F0803FC, 0xBCF6E230,
@@ -782,4 +785,78 @@ namespace ModernKeePassLib.Utility
yield break;
}
}
internal sealed class ArrayHelperEx<T> : IEqualityComparer<T[]>, IComparer<T[]>
where T : IEquatable<T>, IComparable<T>
{
public int GetHashCode(T[] obj)
{
if(obj == null) throw new ArgumentNullException("obj");
uint h = 0xC17962B7U;
unchecked
{
int n = obj.Length;
for(int i = 0; i < n; ++i)
{
h += (uint)obj[i].GetHashCode();
h = MemUtil.RotateLeft32(h * 0x5FC34C67U, 13);
}
}
return (int)h;
}
/* internal ulong GetHashCodeEx(T[] obj)
{
if(obj == null) throw new ArgumentNullException("obj");
ulong h = 0x207CAC8E509A3FC9UL;
unchecked
{
int n = obj.Length;
for(int i = 0; i < n; ++i)
{
h += (uint)obj[i].GetHashCode();
h = MemUtil.RotateLeft64(h * 0x54724D3EA2860CBBUL, 29);
}
}
return h;
} */
public bool Equals(T[] x, T[] y)
{
if(object.ReferenceEquals(x, y)) return true;
if((x == null) || (y == null)) return false;
int n = x.Length;
if(n != y.Length) return false;
for(int i = 0; i < n; ++i)
{
if(!x[i].Equals(y[i])) return false;
}
return true;
}
public int Compare(T[] x, T[] y)
{
if(object.ReferenceEquals(x, y)) return 0;
if(x == null) return -1;
if(y == null) return 1;
int n = x.Length, m = y.Length;
if(n != m) return ((n < m) ? -1 : 1);
for(int i = 0; i < n; ++i)
{
T tX = x[i], tY = y[i];
if(!tX.Equals(tY)) return tX.CompareTo(tY);
}
return 0;
}
}
}

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2017 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2018 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-2017 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2018 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
@@ -101,6 +101,9 @@ namespace ModernKeePassLib.Utility
// 1632:
// RichTextBox rendering bug for bold/italic text.
// https://sourceforge.net/p/keepass/bugs/1632/
// 1690:
// Removing items from a list view doesn't work properly.
// https://sourceforge.net/p/keepass/bugs/1690/
// 2139:
// Shortcut keys are ignored.
// https://sourceforge.net/p/keepass/feature-requests/2139/
@@ -157,6 +160,9 @@ namespace ModernKeePassLib.Utility
// 2449941153:
// RichTextBox doesn't properly escape '}' when generating RTF data.
// https://sourceforge.net/p/keepass/discussion/329221/thread/920722a1/
// 3471228285:
// Mono requires command line arguments to be encoded differently.
// https://sourceforge.net/p/keepass/discussion/329221/thread/cee6bd7d/
// 3574233558:
// Problems with minimizing windows, no content rendered.
// https://sourceforge.net/p/keepass/discussion/329220/thread/d50a79d6/

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2014 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2018 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
@@ -21,24 +21,22 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
#if ModernKeePassLib
using Windows.Security.Cryptography;
using ModernKeePassLib.Cryptography;
#else
using System.Security.Cryptography;
#endif
using ModernKeePassLib.Collections;
using ModernKeePassLib.Cryptography;
using ModernKeePassLib.Cryptography.PasswordGenerator;
using ModernKeePassLib.Native;
using ModernKeePassLib.Security;
using ModernKeePassLib.Resources;
namespace ModernKeePassLib.Utility
{
@@ -225,11 +223,11 @@ namespace ModernKeePassLib.Utility
List<StrEncodingInfo> l = new List<StrEncodingInfo>();
l.Add(new StrEncodingInfo(StrEncodingType.Default,
#if ModernKeePassLib || KeePassRT
StrUtil.Utf8.WebName, StrUtil.Utf8, 1, null));
#if ModernKeePassLib ||KeePassUAP
"Unicode (UTF-8)", StrUtil.Utf8, 1, new byte[] { 0xEF, 0xBB, 0xBF }));
#else
#if !KeePassLibSD
Encoding.Default.EncodingName,
Encoding.Default.EncodingName,
#else
Encoding.Default.WebName,
#endif
@@ -304,20 +302,27 @@ namespace ModernKeePassLib.Utility
}
/// <summary>
/// Convert a string into a valid HTML sequence representing that string.
/// Convert a string to a HTML sequence representing that string.
/// </summary>
/// <param name="str">String to convert.</param>
/// <returns>String, HTML-encoded.</returns>
public static string StringToHtml(string str)
{
return StringToHtml(str, false);
}
internal static string StringToHtml(string str, bool bNbsp)
{
Debug.Assert(str != null); if(str == null) throw new ArgumentNullException("str");
str = str.Replace(@"&", @"&amp;");
str = str.Replace(@"&", @"&amp;"); // Must be first
str = str.Replace(@"<", @"&lt;");
str = str.Replace(@">", @"&gt;");
str = str.Replace("\"", @"&quot;");
str = str.Replace("\'", @"&#39;");
if(bNbsp) str = str.Replace(" ", @"&nbsp;"); // Before <br />
str = NormalizeNewLines(str, false);
str = str.Replace("\n", @"<br />" + Environment.NewLine);
@@ -833,10 +838,10 @@ namespace ModernKeePassLib.Utility
#if ModernKeePassLib
if (bExpNum != bExpNumY) return StringComparer.OrdinalIgnoreCase.Compare(strX, strY);
#else
if(bExpNum != bExpNumY) return string.Compare(strX, strY, true);
if(bExpNum != bExpNumY) return string.Compare(strX, strY, true);
#endif
int pX = 0;
int pX = 0;
int pY = 0;
while((pX < cX) && (pY < cY))
{
@@ -894,7 +899,7 @@ namespace ModernKeePassLib.Utility
}
}
if(bStrCmp)
{
{
#if ModernKeePassLib
int c = StringComparer.OrdinalIgnoreCase.Compare(strPartX, strPartY);
#else

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2014 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2018 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
@@ -19,9 +19,9 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Globalization;
using System.Text;
using ModernKeePassLib.Interfaces;

View File

@@ -1,6 +1,6 @@
/*
KeePass Password Safe - The Open-Source Password Manager
Copyright (C) 2003-2014 Dominik Reichl <dominik.reichl@t-online.de>
Copyright (C) 2003-2018 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
@@ -19,13 +19,12 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
#if ModernKeePassLib
//using PCLStorage;
using Windows.Storage;
#endif
@@ -56,7 +55,7 @@ namespace ModernKeePassLib.Utility
#else
get { return Path.DirectorySeparatorChar; }
#endif
}
}
/// <summary>
/// Get the directory (path) of a file name. The returned string may be
@@ -650,8 +649,7 @@ namespace ModernKeePassLib.Utility
try
{
if(Directory.Exists(strDir) == false)
Directory.CreateDirectory(strDir);
if(!Directory.Exists(strDir)) Directory.CreateDirectory(strDir);
}
catch(Exception) { Debug.Assert(false); }