Handle corrupt ASCII85Decode inline images with truncated EOD markers (issue 11385)
In the PDF document in question, there's an ASCII85Decode inline image where the '>' part of EOD (end-of-data) marker is missing; hence the PDF document is corrupt.
This commit is contained in:
		
							parent
							
								
									514b500a6c
								
							
						
					
					
						commit
						5c0336872e
					
				@ -344,6 +344,8 @@ class Parser {
 | 
			
		||||
    let startPos = stream.pos, ch, length;
 | 
			
		||||
    while ((ch = stream.getByte()) !== -1) {
 | 
			
		||||
      if (ch === TILDE) {
 | 
			
		||||
        const tildePos = stream.pos;
 | 
			
		||||
 | 
			
		||||
        ch = stream.peekByte();
 | 
			
		||||
        // Handle corrupt PDF documents which contains whitespace "inside" of
 | 
			
		||||
        // the EOD marker (fixes issue10614.pdf).
 | 
			
		||||
@ -355,6 +357,14 @@ class Parser {
 | 
			
		||||
          stream.skip();
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
        // Handle corrupt PDF documents which contains truncated EOD markers,
 | 
			
		||||
        // where the '>' character is missing (fixes issue11385.pdf).
 | 
			
		||||
        if (stream.pos > tildePos) {
 | 
			
		||||
          const maybeEI = stream.peekBytes(2);
 | 
			
		||||
          if (maybeEI[0] === /* E = */ 0x45 && maybeEI[1] === /* I = */ 0x49) {
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    length = stream.pos - startPos;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										1
									
								
								test/pdfs/issue11385.pdf.link
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/pdfs/issue11385.pdf.link
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
https://github.com/mozilla/pdf.js/files/3926686/problematic.pdf
 | 
			
		||||
@ -1595,6 +1595,14 @@
 | 
			
		||||
       "lastPage": 1,
 | 
			
		||||
       "type": "eq"
 | 
			
		||||
    },
 | 
			
		||||
    {  "id": "issue11385",
 | 
			
		||||
       "file": "pdfs/issue11385.pdf",
 | 
			
		||||
       "md5": "cc04b23b845366857426a5aa6acf227b",
 | 
			
		||||
       "rounds": 1,
 | 
			
		||||
       "link": true,
 | 
			
		||||
       "lastPage": 1,
 | 
			
		||||
       "type": "eq"
 | 
			
		||||
    },
 | 
			
		||||
    {  "id": "issue6071",
 | 
			
		||||
       "file": "pdfs/issue6071.pdf",
 | 
			
		||||
       "md5": "2e08526d8e7c9ba4269fc12ef488d3eb",
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user