Skip to content

Commit d7f9a15

Browse files
author
Maximilian Fischer
committed
Fix PdfReaderException by ignoring single backslash
As stated in pdf specification: Within a literal string, the backslash () is used as an escape character for various purposes, such as to include newline characters, nonprinting ASCII characters, unbalanced parentheses, or the backslash character itself in the string. The char-acter immediately following the backslash determines its precise interpretation (see Table 3.2). If the character following the backslash is not one of those shown in the table, the backslash is ignored. When opening a pdf with PdfSharpCore, it should ignore the backslash if no character with special meaning follows it. This commit removes the exception and ignores the backslash for literal strings. This can also be done when the digit after a backslash is greater than 7.
1 parent bc8f86d commit d7f9a15

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

PdfSharpCore/Pdf.IO/Lexer.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ public Symbol ScanLiteralString()
500500
{
501501
// Octal character code.
502502
if (ch >= '8')
503-
ParserDiagnostics.HandleUnexpectedCharacter(ch);
503+
break; // Since the first possible octal character is not valid,
504+
// the backslash is ignored.
504505

505506
int n = ch - '0';
506507
if (char.IsDigit(_nextChar)) // Second octal character.
@@ -521,12 +522,6 @@ public Symbol ScanLiteralString()
521522
}
522523
ch = (char)n;
523524
}
524-
else
525-
{
526-
//TODO
527-
// Debug.As sert(false, "Not implemented; unknown escape character.");
528-
ParserDiagnostics.HandleUnexpectedCharacter(ch);
529-
}
530525
break;
531526
}
532527
break;

0 commit comments

Comments
 (0)