Skip to content

Commit

Permalink
fix for pdf that has %PDF in first 1024 bytes instead of at very begi…
Browse files Browse the repository at this point in the history
…nning and better error message in case of missing js
  • Loading branch information
urule99 committed May 26, 2011
1 parent 8ec3a6b commit 741b133
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions jsunpackn.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def decodeJShelper(self,to_write,fixErrors=3):
else:
self.rooturl[self.url].log(self.OPTIONS.veryverbose,-1,'%s' % re.sub('\n','\n\terror: ',errors))
except Exception, e:
self.rooturl[self.url].log(self.OPTIONS.veryverbose,-1,'Error: Fatal error in decodeJS: %s' % e)
self.rooturl[self.url].log(self.OPTIONS.veryverbose,-1,'Error: Fatal error in decodeJS: %s (probably you are missing "js" in your path)' % e)
return '',(time.time()-begin)

return decoded,(time.time()-begin)
Expand Down Expand Up @@ -966,7 +966,7 @@ def main_decoder(self, data, url, tcpaddr = [], lastModified = ''):


pdfjs,pdfjs_header = '',''
if data.startswith('%PDF-') or data.startswith('%%PDF-'):
if 0 <= data[0:1024].find('%PDF-') <= 1024:
isPDF = True
self.rooturl[self.url].filetype = 'PDF'
mypdf = pdf.pdf(data,'PDF-'+self.url)
Expand Down
2 changes: 1 addition & 1 deletion pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def decryptRC4(self,data,key):


def is_valid(self):
if 0 <= self.indata.find('%PDF-') <= 1024:
if 0 <= self.indata[0:1024].find('%PDF-') <= 1024:
return True
return False

Expand Down

0 comments on commit 741b133

Please sign in to comment.