1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-10-03 01:10:45 +00:00
TiddlyWiki5/core/modules/utils
Robin Munn 326ae61929
Fix encodebase64 and decodebase64 filters (#7683)
* Fix encodebase64 and decodebase64 filters

The documentation for encodebase64 says that the input is treated as
binary data, but in fact the input is being treated as text data, with
an extra UTF-8 encoding step being performed first.

Likewise, the decodebase64 documentation says that it outputs binary
data, but in fact it will do a UTF-8 decoding step before producing
output, which will in fact garble binary data.

This commit changes the behavior of encodebase64 and decodebase64 to
match what the documentation says they do. It also adds an optional
`text` suffix to both filters to keep the current behavior.

Finally, an optional `urlsafe` suffix is added to both filters to allow
them to use the "URL-safe" variant of base64 (using `-` instead of `+`
and `_` instead of `/`).

* Try to fix failing test

Turns out a little more than this is going to be needed.

* Fix binary base64 encoding, including unit tests

* Update base64 filter documentation

* Can't use replaceAll, too new

Have to use String.replace with a global regex instead

* Replace uses of window.btoa() in rest of code

Since window.btoa() is not available under Node.js, we'll replace all
uses of it with the $tw.utils.base64encode() function that now works
correctly for binary data.

* Add link to UTF-8 glossary definition at MDN
2023-10-18 16:08:56 +01:00
..
base64-utf8 Fix incorrect base64 encoding of astral-plane text (#4813) 2020-08-17 17:33:46 +01:00
diff-match-patch Incorporate “diff” engine to show visual differences (#3112) 2018-03-16 20:38:35 +00:00
dom Fix encodebase64 and decodebase64 filters (#7683) 2023-10-18 16:08:56 +01:00
crypto.js Introduce JSON parse utility function with error handling (#6401) 2022-02-21 15:29:25 +00:00
csv.js CSV parser improvements (#7042) 2022-11-20 17:51:01 +00:00
edition-info.js Introduce JSON parse utility function with error handling (#6401) 2022-02-21 15:29:25 +00:00
escapecss.js Change css-escape-polyfill to a tw uitility method (#5552) 2021-04-02 09:25:01 +01:00
fakedom.js Optimise fake dom 2022-09-23 18:09:45 +01:00
filesystem.js Node.js: Prefer .tid format when a _canonical_uri field present 2023-02-03 19:22:43 +00:00
linked-list.js Linked-List refactor (#6056) 2022-11-27 17:48:08 +00:00
logger.js Log message not to have spaces and <empty string> (#6947) 2022-09-15 12:10:33 +01:00
parsetree.js Fix handling of orderedattributes when adding classes/styles 2022-10-16 17:27:46 +01:00
performance.js style(App) eliminate whitespace at the end of code lines (#5735) 2021-05-30 19:20:17 +01:00
pluginmaker.js Introduce JSON parse utility function with error handling (#6401) 2022-02-21 15:29:25 +00:00
transliterate.js Additional transliteration pairs 2021-09-24 18:29:40 +01:00
utils.js Fix encodebase64 and decodebase64 filters (#7683) 2023-10-18 16:08:56 +01:00