vzhd1701 / enex2notion

Import Evernote ENEX files to Notion
MIT License
425 stars 35 forks source link

[Bug]: Crash on application/x-msdownload (.exe) and application/octet-stream (.js) attachments, because .exe and .js upload not allowed #20

Closed TBT-TBT closed 2 years ago

TBT-TBT commented 2 years ago

enex2notion version

0.2.5

What OS are you using?

MacOS

OS Version / Linux distribution

MacOS 12.2

Bug description

It seems application/x-msdownload attachments, in this case an .exe file lead to a crash. First, the script tries to reupload the page four times, then the log in the excerpt happens.

As can be seen with "requests.exceptions.HTTPError: Uploading .exe files is not allowed" .exe files cannot be uploaded.

In my case I deleted the .exe attachment, exported the notebook again and then continued (thanks for the "done" file) with the same note but without .exe file. Then it went through.

EDIT: the same goes for application/octet-stream and .js . JavaScript Files as attachments in Evernote notes cannot be uploaded.

It would be cool maybe for enex2notion to cope with this without crashing? Maybe jump over the .exe file without upload? Evven if not, I just wanted to leave this here as a hint for others who have the same problem.

And I wanted to thank the creator of this tool for doing what Notion was not able to: create an amazing import tool from Evernote to Notion WHICH WORKS!

Log excerpt

WARNING: Failed to upload note 'MYNOTENAME' to Notion! Retrying...
INFO: Creating new page for note 'MYNOTENAME'
Uploading 'MYNOTENAME' |############################    | 7/8ERROR: Got 400 error attempting to POST to getUploadFileUrl, with data: {
  "bucket": "secure",
  "name": "MYFILECHANGED.exe",
  "contentType": "application/x-msdownload"
}

Traceback (most recent call last):
  File "enex2notion/enex_uploader.py", line 37, in upload_note
  File "enex2notion/note_uploader.py", line 16, in upload_block
  File "enex2notion/note_uploader.py", line 30, in _upload_file
  File "notion/client.py", line 260, in post
requests.exceptions.HTTPError: Uploading .exe files is not allowed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "enex2notion/__main__.py", line 4, in <module>
  File "enex2notion/cli.py", line 152, in main
  File "enex2notion/cli.py", line 147, in cli
  File "enex2notion/cli.py", line 89, in upload
  File "enex2notion/cli.py", line 46, in _upload_note
  File "enex2notion/enex_uploader.py", line 43, in upload_note
enex2notion.enex_uploader.NoteUploadFailException
[70053] Failed to execute script '__main__' due to unhandled exception!
vzhd1701 commented 2 years ago

File blocks with js, exe and com file extensions are now dropped with a warning (https://github.com/vzhd1701/enex2notion/commit/e6e6fba7815ab7de727ffd2a3feec8d5ba00ef33)