mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	Merge pull request #2903 from radarhere/eps
Allow for an empty line in EPS header data
This commit is contained in:
		
						commit
						bbe8076d67
					
				| 
						 | 
				
			
			@ -227,9 +227,11 @@ class EpsImageFile(ImageFile.ImageFile):
 | 
			
		|||
        #
 | 
			
		||||
        # Load EPS header
 | 
			
		||||
 | 
			
		||||
        s = fp.readline().strip('\r\n')
 | 
			
		||||
        s_raw = fp.readline()
 | 
			
		||||
        s = s_raw.strip('\r\n')
 | 
			
		||||
 | 
			
		||||
        while s:
 | 
			
		||||
        while s_raw:
 | 
			
		||||
            if s:
 | 
			
		||||
                if len(s) > 255:
 | 
			
		||||
                    raise SyntaxError("not an EPS file")
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -271,9 +273,10 @@ class EpsImageFile(ImageFile.ImageFile):
 | 
			
		|||
                    else:
 | 
			
		||||
                        raise IOError("bad EPS header")
 | 
			
		||||
 | 
			
		||||
            s = fp.readline().strip('\r\n')
 | 
			
		||||
            s_raw = fp.readline()
 | 
			
		||||
            s = s_raw.strip('\r\n')
 | 
			
		||||
 | 
			
		||||
            if s[:1] != "%":
 | 
			
		||||
            if s and s[:1] != "%":
 | 
			
		||||
                break
 | 
			
		||||
 | 
			
		||||
        #
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										
											BIN
										
									
								
								Tests/images/zero_bb_emptyline.eps
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/zero_bb_emptyline.eps
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -278,6 +278,16 @@ class TestFileEps(PillowTestCase):
 | 
			
		|||
        # Assert
 | 
			
		||||
        self.assertEqual(img.mode, "RGB")
 | 
			
		||||
 | 
			
		||||
    def test_emptyline(self):
 | 
			
		||||
        # Test file includes an empty line in the header data
 | 
			
		||||
        emptyline_file = "Tests/images/zero_bb_emptyline.eps"
 | 
			
		||||
 | 
			
		||||
        image = Image.open(emptyline_file)
 | 
			
		||||
        image.load()
 | 
			
		||||
        self.assertEqual(image.mode, "RGB")
 | 
			
		||||
        self.assertEqual(image.size, (460, 352))
 | 
			
		||||
        self.assertEqual(image.format, "EPS")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    unittest.main()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user