1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-26 03:27:18 +00:00
TiddlyWiki5/core/modules/savers
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
..
andtidwiki.js Adds $tw.utils.decodeURISafe and $tw.utils.decodeURIComponentSafe (#5999) 2021-08-29 13:39:32 +01:00
custom.js add override saver (#4908) 2020-10-28 11:58:48 +00:00
download.js Adds $tw.utils.decodeURISafe and $tw.utils.decodeURIComponentSafe (#5999) 2021-08-29 13:39:32 +01:00
fsosaver.js Ensure that savers invoke the callback 2014-08-27 09:59:01 +01:00
gitea.js Introduce JSON parse utility function with error handling (#6401) 2022-02-21 15:29:25 +00:00
github.js Fix encodebase64 and decodebase64 filters (#7683) 2023-10-18 16:08:56 +01:00
gitlab.js Introduce JSON parse utility function with error handling (#6401) 2022-02-21 15:29:25 +00:00
manualdownload.js Ensure that savers invoke the callback 2014-08-27 09:59:01 +01:00
msdownload.js Ensure that savers invoke the callback 2014-08-27 09:59:01 +01:00
put.js Show server response as error message in put saver (#6589) 2022-04-05 17:06:56 +01:00
tiddlyfox.js Adds $tw.utils.decodeURISafe and $tw.utils.decodeURIComponentSafe (#5999) 2021-08-29 13:39:32 +01:00
tiddlyie.js Ensure that savers invoke the callback 2014-08-27 09:59:01 +01:00
twedit.js Adds $tw.utils.decodeURISafe and $tw.utils.decodeURIComponentSafe (#5999) 2021-08-29 13:39:32 +01:00
upload.js Show server response as error message in put saver (#6589) 2022-04-05 17:06:56 +01:00