Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent handling/processing of special characters #242

Closed
polarstoat opened this issue Nov 13, 2023 · 3 comments
Closed

Inconsistent handling/processing of special characters #242

polarstoat opened this issue Nov 13, 2023 · 3 comments

Comments

@polarstoat
Copy link

polarstoat commented Nov 13, 2023

When using the client.editLegacyPost method, editing a post that has a body containing unescaped special characters (like é, ä, ½, ʻ, , etc.) causes 400 Bad Request errors.

Error: API error: 400 Bad Request
    at IncomingMessage.<anonymous> (~/repository/node_modules/tumblr.js/lib/tumblr.js:339:13)
    at IncomingMessage.emit (node:events:529:35)
    at endReadableNT (node:internal/streams/readable:1368:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Node.js v18.18.2

If these special non-ASCII characters are then encoded (as &eacute;, &auml;, &frac12;, &#699;, &hellip;, etc.) as HTML4 named references, then they are accepted by the API successfully (note that for some reason HTML5 named references do not then render correctly on the Tumblr blog, XML references also work as an alternative to HTML4 though).

However, when then retrieving the post back with the client.blogPosts method with the given post ID and options of { filter: 'raw' }, the post body is returned with these special characters unescaped. This is causing problems for me in detecting changes and whether an update needs to be made to a Tumblr post to keep it synchronised with another data source.

As per the docs, I'd expect using the raw filter to return the data "As entered by the user (no post-processing)".

@sirreal
Copy link
Member

sirreal commented Nov 20, 2023

Thanks for the report! That seems like a valid issue, but from what I can tell the issue is with the API itself and not with this library.

The best place for this type of report is the Tumblr docs repo. Do you mind creating an issue over there?

@sirreal
Copy link
Member

sirreal commented Dec 26, 2023

Thanks for opening the docs issue. I'll close this, it should be handled elsewhere.

@polarstoat
Copy link
Author

To confirm, @cubeghost's pull request #299 fixes this issue. So turns out it was an issue with tumblr.js itself rather than the Tumblr API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants