How can we figure out why certain uuencoded files

2019-07-15 11:19发布

We are trying to decode some uuencoded PDF files that are embedded in a txt file.

The problem we have is that most of the PDF files decoded just fine using Python's uuencode library. Here is the code:

try:
    decoded_file,m=uudecode(fileString)
except:
    decoded_file=''

However, some of the files cannot be opened after they are decoded. We receive the message "There was an error opening this document. The file is damaged and could not be repaired."

The only thing we could find on Google is that our files could've been encoded using base64 and the Python uuencoding module only supports base32. Is there a way that we could tell whether it was uuencoded using base64 or base32?

Here is an example of a txt file that had an embedded uuencoded pdf that we successfully decoded: http://www.sec.gov/Archives/edgar/data/1108046/000000000011020832/0000000000-11-020832.txt

And here is an example of one that failed: http://www.sec.gov/Archives/edgar/data/914257/000000000011005978/0000000000-11-005978.txt

While we are decoding these in Python no errors pop up of any kind and everything seems to be working as it should. What could be causing them to not decode properly? Is there a way we could flag this while we are processing them?

2条回答
【Aperson】
2楼-- · 2019-07-15 11:47
$ python -c "import urllib2; print len(urllib2.urlopen('http://www.sec.gov/Archives/edgar/data/914257/000000000011005978/0000000000-11-005978.txt').read().decode('uu'))"
43124

works just fine.

查看更多
Animai°情兽
3楼-- · 2019-07-15 11:58
>>> uu.decode(open('0000000000-11-005978.txt'))
Warning: Trailing garbage

The source data itself is damaged. This is further evidenced by the .. at the beginning of a line near the end.

查看更多
登录 后发表回答