evernote2md
evernote2md copied to clipboard
Unexpected EOF in CDATA section
Problem statement
Exported all my Evernote notes into a file AllEvernotes.enex
. I've added the release binary to the /usr/local/bin
fodler and it is available on the $PATH.
Using the terminal I change into the Documents
folder where the .enex
file is stored and use the following command: evernote2md ./AllEvernotes.enex
When hit enter I get the following error fairly quickly (5.22s user 0.18s system 100% cpu 5.359 total):
2020/11/14 14:52:59 XML syntax error on line 404: unexpected EOF in CDATA section
Is this a known issue? I've had the same error on Ubuntu and now Manjaro.
Hello @mweitzel2005, thanks for reporting the problem here!
I didn't see this error before. It may be caused by an unexpected sequence of characters in the note, but it's hard to guess without looking at the export file. Here is what you can do:
Try to run the latest version of the app using the same command with the --debug
flag. You will see which note was processed last before the app crashed.
evernote2md --debug ./AllEvernotes.enex
Then you can export all notes except the one that causes an issue and check if this time evernote2md
finishes successfully. If the note that causes a syntax error doesn't contain any personal information, I'd appreciate it if you could export it alone and share it here. Maybe I can fix this bug.
Without additional info, there is not much I can do.
@wormi4ok I need to give you some more examples on the escaped characters issue, so I thought I would export some more notes to show you what happens. But several of the notes are crashing the script exactly as described in this issue. Here's a sample note that crashes the script. cdata.issue.enex.zip
Looks to me like Evernote nests one or more <![CDATA[>]]>
inside the <![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
before closing out the first tag and that's probably what's killing the script. I don't think CDATA tags can legally be nested, but Evernote's doing it.
https://en.wikipedia.org/wiki/CDATA#Nesting
Try to run the latest version of the app using the same command with the
--debug
flag. You will see which note was processed last before the app crashed.evernote2md --debug ./AllEvernotes.enex
Then you can export all notes except the one that causes an issue and check if this time
evernote2md
finishes successfully.
I am getting this same error, run with --debug
but the app crashes and not a single note is exported. Ideally I would expect a warning with each note that failed to export, so at least I can get the rest
All right, let's reopen the issue and see how we can handle these cases gracefully.
From a notebook with 2800 notes, 7 had the CDATA problem. I did manage to solve my case, but I still think some robustness (considering those errors do happen) would be gold for future users
From a notebook with 2800 notes, 7 had the CDATA problem. I did manage to solve my case, but I still think some robustness (considering those errors do happen) would be gold for future users
Any work around solution?
└─ $ evernote2md.exe --debug --tagTemplate "#{{tag}}" ./evernotes_default_20221113.enex ./notes/
2022/11/13 12:38:01 [DEBUG] Decoding a file: C:\Downloads\evernotes\evernotes_default_20221113.enex
2022/11/13 12:38:05 [ERROR] decoding note Cloudfoundry API: XML syntax error on line 12: unexpected EOF in CDATA section
Head lines of File evernotes_default_20221113.enex
└─ $ head -n 20 evernotes_default_20221113.enex
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export4.dtd">
<en-export export-date="20221213T031804Z" application="Evernote" version="10.48.4">
<note>
<title>- Business Card</title>
<created>20190311T081534Z</created>
<updated>20190311T081535Z</updated>
<note-attributes>
<latitude>22.309970408293626</latitude>
<longitude>114.22493127362134</longitude>
<altitude>38.33749008178711</altitude>
<source>mobile.iphone</source>
<source-application>businesscard</source-application>
<content-class>evernote.contact.1</content-class>
</note-attributes>
<content>
<![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note style="padding-left: 0px 10px 0px 10px;
font-size: 14px;
Version
└─ $ evernote2md.exe --version Version: 0.18.0
Introduction yarle-evernote-to-md to handle enex files without this problem.
https://www.npmjs.com/package/yarle-evernote-to-md
I'm getting the same issue as @fgarcia. I was hoping the converter would simply fail gracefully, adding warnings on completion in terminal, and not block the other files that converted successfully. In my case I'm downloading >5 gig of notes, and it seems only one is blocking the whole process.
2023/01/02 12:19:07 [ERROR] decoding note Go To meeting credentials: XML syntax error on line 26: unexpected EOF in CDATA section
Yeah, sorry to hear that @ariakerstein. The way I've implemented enex
package is not flexible enough and due this flaw this issue and also #66 got stuck and not resolved for so long.
I have a work-in-progress local branch to redesign the package, but don't have enough spare time to finish the work. I'll try to address this issue in the next release.
No issues! I was able to resolve my issue by passing the tag flag params "#{{tag}}"
as noted above. Thank you and keep up the great work!
I've released a new version that should handle incorrectly formatted notes with nested CDATA sections and convert them correctly. It works for the example @dwertheimer shared, at least.