fix bug where hex tokens for document identifier lost bytes due to encoding

This commit is contained in:
Eliot Jones
2019-12-18 14:54:56 +00:00
parent dab64ec406
commit a167d4c1dd
3 changed files with 27 additions and 10 deletions

View File

@@ -42,9 +42,27 @@
{
this.encryptionDictionary = encryptionDictionary;
var documentIdBytes = trailerDictionary.Identifier != null && trailerDictionary.Identifier.Count == 2 ?
OtherEncodings.StringAsLatin1Bytes(trailerDictionary.Identifier[0])
: EmptyArray<byte>.Instance;
byte[] documentIdBytes;
if (trailerDictionary.Identifier != null && trailerDictionary.Identifier.Count == 2)
{
var token = trailerDictionary.Identifier[0];
switch (token)
{
case HexToken hex:
documentIdBytes = hex.Bytes.ToArray();
break;
default:
documentIdBytes = OtherEncodings.StringAsLatin1Bytes(token.Data);
break;
}
}
else
{
documentIdBytes = EmptyArray<byte>.Instance;
}
password = password ?? string.Empty;