File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -562,15 +562,19 @@ public Symbol ScanHexadecimalString()
562
562
ScanNextChar ( true ) ;
563
563
break ;
564
564
}
565
- if ( char . IsLetterOrDigit ( _currChar ) )
565
+ if ( IsHexChar ( _currChar ) )
566
566
{
567
- hex [ 0 ] = char . ToUpper ( _currChar ) ;
568
- hex [ 1 ] = char . ToUpper ( _nextChar ) ;
569
- int ch = int . Parse ( new string ( hex ) , NumberStyles . AllowHexSpecifier ) ;
567
+ hex [ 0 ] = _currChar ;
568
+ hex [ 1 ] = IsHexChar ( _nextChar ) ? _nextChar : ' ' ;
569
+ int ch = int . Parse ( new string ( hex ) , NumberStyles . HexNumber ) ;
570
570
_token . Append ( Convert . ToChar ( ch ) ) ;
571
571
ScanNextChar ( true ) ;
572
- ScanNextChar ( true ) ;
572
+ if ( _currChar != '>' )
573
+ ScanNextChar ( true ) ;
573
574
}
575
+ else
576
+ // prevent endless loop in case _currChar is neither '>' nor a hex-char nor whitespace
577
+ ScanNextChar ( true ) ;
574
578
}
575
579
string chars = _token . ToString ( ) ;
576
580
int count = chars . Length ;
@@ -585,6 +589,13 @@ public Symbol ScanHexadecimalString()
585
589
return _symbol = Symbol . HexString ;
586
590
}
587
591
592
+ internal static bool IsHexChar ( char c )
593
+ {
594
+ return char . IsDigit ( c ) ||
595
+ ( c >= 'A' && c <= 'F' ) ||
596
+ ( c >= 'a' && c <= 'f' ) ;
597
+ }
598
+
588
599
/// <summary>
589
600
/// Move current position one character further in PDF stream.
590
601
/// </summary>
You can’t perform that action at this time.
0 commit comments