kerchen / kerchen/export_gr2evernote

Bad characters in subject (aka title)

Open
#11 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
64
Forks
10
PR merge metrics
No merged PRs in 30d

Description

I found a few items in my JSON that included characters XML doesn't like including newlines and ampersands. I resolved it as follows:

Add to imports:
from xml.sax.saxutils import escape
import re

Change subject to:
subject = escape(re.sub(' +',' ',re.sub('\n',' ',s["title"]))).rstrip().encode(char_encoding, 'replace')

The escape helps find ampersands, etc, then the nested re.sub replaces newlines and multiple spaces. Finally an rstrip to clean trailing spaces for neatness.

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the exporter code that constructs the subject from s["title"], then review how the XML subject is encoded. Verify that titles with newlines, repeated spaces, ampersands, and other XML-sensitive characters produce a cleaned, valid subject without trailing spaces.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.