home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 706834800

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions issue performed_via_github_app
https://github.com/dogsheep/evernote-to-sqlite/issues/5#issuecomment-706834800 https://api.github.com/repos/dogsheep/evernote-to-sqlite/issues/5 706834800 MDEyOklzc3VlQ29tbWVudDcwNjgzNDgwMA== 9599 2020-10-12T03:24:57Z 2020-10-16T20:16:28Z MEMBER

Here's my first attempt at a plugin for this: ```python from datasette import hookimpl import jinja2

START = "<en-note" END = "</en-note>" TEMPLATE = """

{}
""".strip()

EN_MEDIA_SCRIPT = """ Array.from(document.querySelectorAll('en-media')).forEach(el => { let hash = el.getAttribute('hash'); let type = el.getAttribute('type'); let path = /evernote/resources_data/${hash}.json?_shape=array; fetch(path).then(r => r.json()).then(rows => { let b64 = rows[0].data.encoded; let data = data:${type};base64,${b64}; el.innerHTML = <img style="max-width: 300px" src="${data}">; }); }); """

@hookimpl def render_cell(value, table): if not table: # Don't render content from arbitrary SQL queries, could be XSS hole return if not value or not isinstance(value, str): return value = value.strip() if value.startswith(START) and value.endswith(END): trimmed = value[len(START) : -len(END)] trimmed = trimmed.split(">", 1)[1] # Replace those horrible double newlines trimmed = trimmed.replace("


", "
") return jinja2.Markup(TEMPLATE.format(trimmed))

@hookimpl def extra_body_script(): return EN_MEDIA_SCRIPT ``` It works!

It does however demonstrate that Evernote's "clip this webpage" feature means there is a LOT of weird HTML that can get into a note. It looks like they've filtered out the scripts but I wouldn't bet on it - they certainly don't filter out many of the inline styles. So running Bleach is almost certainly a good idea.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
718938889  
Powered by Datasette · Queries took 1.066ms · About: github-to-sqlite