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()
562562 ScanNextChar ( true ) ;
563563 break ;
564564 }
565- if ( char . IsLetterOrDigit ( _currChar ) )
565+ if ( IsHexChar ( _currChar ) )
566566 {
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 ) ;
570570 _token . Append ( Convert . ToChar ( ch ) ) ;
571571 ScanNextChar ( true ) ;
572- ScanNextChar ( true ) ;
572+ if ( _currChar != '>' )
573+ ScanNextChar ( true ) ;
573574 }
575+ else
576+ // prevent endless loop in case _currChar is neither '>' nor a hex-char nor whitespace
577+ ScanNextChar ( true ) ;
574578 }
575579 string chars = _token . ToString ( ) ;
576580 int count = chars . Length ;
@@ -585,6 +589,13 @@ public Symbol ScanHexadecimalString()
585589 return _symbol = Symbol . HexString ;
586590 }
587591
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+
588599 /// <summary>
589600 /// Move current position one character further in PDF stream.
590601 /// </summary>
You can’t perform that action at this time.
0 commit comments