@@ -20,11 +20,17 @@ class CompressedObjectByteOffsetParser {
2020 public static function parse (Stream $ stream , int $ startOffsetObject , int $ endOffsetObject , Dictionary $ dictionary ): CompressedObjectByteOffsets {
2121 $ startStreamPos = $ stream ->getStartNextLineAfter (Marker::STREAM , $ startOffsetObject , $ endOffsetObject )
2222 ?? throw new ParseFailureException (sprintf ('Unable to locate marker %s ' , Marker::STREAM ->value ));
23- $ endStreamPos = $ stream ->firstPos (Marker::END_STREAM , $ startStreamPos , $ endOffsetObject )
24- ?? throw new ParseFailureException (sprintf ('Unable to locate marker %s ' , Marker::END_STREAM ->value ));
25- $ eolPos = $ stream ->getEndOfCurrentLine ($ endStreamPos - 1 , $ endOffsetObject )
26- ?? throw new ParseFailureException (sprintf ('Unable to locate marker %s ' , WhitespaceCharacter::LINE_FEED ->value ));
27- $ content = bin2hex (CompressedObjectContentParser::parseBinary ($ stream , $ startStreamPos , $ eolPos - $ startStreamPos , $ dictionary ));
23+ if ($ dictionary ->getTypeForKey (DictionaryKey::LENGTH ) === IntegerValue::class && ($ lengthInteger = $ dictionary ->getValueForKey (DictionaryKey::LENGTH , IntegerValue::class)) !== null ) {
24+ $ length = $ lengthInteger ->value ;
25+ } else {
26+ $ endStreamPos = $ stream ->firstPos (Marker::END_STREAM , $ startStreamPos , $ endOffsetObject )
27+ ?? throw new ParseFailureException (sprintf ('Unable to locate marker %s ' , Marker::END_STREAM ->value ));
28+ $ eolPos = $ stream ->getEndOfCurrentLine ($ endStreamPos - 1 , $ endOffsetObject )
29+ ?? throw new ParseFailureException (sprintf ('Unable to locate marker %s ' , WhitespaceCharacter::LINE_FEED ->value ));
30+ $ length = $ eolPos - $ startStreamPos ;
31+ }
32+
33+ $ content = bin2hex (CompressedObjectContentParser::parseBinary ($ stream , $ startStreamPos , $ length , $ dictionary ));
2834 $ first = $ dictionary ->getValueForKey (DictionaryKey::FIRST , IntegerValue::class)
2935 ?? throw new RuntimeException ('Expected a dictionary entry for "First", none found ' );
3036 $ buffer = new InfiniteBuffer ();
0 commit comments