PrivateBin/tst
rugk 2c4dd2594c fix: do not encode source JSON translation string resulting in wrong display of special characters like '
Fixes #1712

Disclosure: Coded with help of Copiot. (description wrtten by me)

So this does indeed loosen the encoding a bit. However, IMHO, it was neither better before though. You could always bypass the encoding for `args{0]` when  you just include `<a` (or the other tag) somewhere or so.

**One important notice:** This was (due to the exceptions before and afterwards) valid before and also now: Translators **could** (and can) if they have malicious intent, inject/do "XSS attacks".
Thus, translations PRs (also from Crowdin) should be reviewed for wild HTML code inside translations. I suppose this is easy to fix, but anyway a valid risk.

But IMHO, we should teat the JSON files being part of our source code as a "trusted source". In the end, such an attak is basicaly just ends up being injecting malicious code. I hope such contributors would be detected.

References I explicitly checked again to not introduce an XSS here: https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html and the PHP doc for he HTML encoding.

I feel the safter way obviously would be encoding the _whole_ string _after_ translation (just like you should apply DOMPurify after everything), but as explained it was not done before and would break compatibility. Also, I looked through the sources and I see no risk described by doing it only for the "dangerous" "untrusted" inputs.
Only here is a notice that `%s` shall not be used in some contexts, for example to define a tag: https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html#dangerous-contexts (obviously in such a case, attacks may be possible even with encoding; but again; this is nothing new)

The basic "problem" of it all is: We want HTML to be translated/be usable in our translation. If we'd get rid of that, we would get for sure rid of all such XSS attack possibilities. But that woud be a bigger refactoring, so IMHO, this here is fine for a fix for the issue at hand.

Ah another point: I think the `is_int` check is harmless, but it's also kinda useless. Maybe it is some kind of obscure performance optimisation. (Yeah ints have nothing to encode as they have nothing that could be used for XSS, but they could also just be passed through that function.)
2025-11-13 10:52:08 +00:00
..
Data fix deprecated creation of dynamic property 2025-07-19 21:30:05 +02:00
Persistence replaced the term "paste" with the more generic "document" 2025-07-24 10:46:31 +02:00
Bootstrap.php partially revert #1559 2025-11-10 17:31:35 +01:00
ConfigurationTest.php removed support for privatebin_data, privatebin_db & zerobin_db model class configurations 2025-07-05 17:45:02 +02:00
ControllerTest.php replaced the term "paste" with the more generic "document" 2025-07-25 08:16:08 +02:00
ControllerWithDbTest.php enable strict types in PHP 2024-06-04 07:13:55 +02:00
ControllerWithGcsTest.php enable strict types in PHP 2024-06-04 07:13:55 +02:00
FilterTest.php Switch from binary bytes to SI-units 2025-07-23 21:06:20 +03:00
FormatV2Test.php pass by reference, closes #858 2025-03-11 08:22:21 +01:00
I18nTest.php fix: do not encode source JSON translation string resulting in wrong display of special characters like ' 2025-11-13 10:52:08 +00:00
JsonApiTest.php updated test cases, added clarity in error messages 2025-08-20 01:23:06 +00:00
MigrateTest.php pass by reference, closes #858 2025-03-13 09:22:27 +01:00
ModelTest.php replaced the term "paste" with the more generic "document" 2025-07-25 08:16:08 +02:00
phpunit.xml Merge branch 'master' into php8 2022-11-17 06:04:12 +01:00
RequestTest.php add failing test case, dedup code 2024-10-23 08:17:13 +02:00
TemplateSwitcherTest.php Unit test on escaping the template directory 2025-11-10 12:00:29 +01:00
ViewTest.php apply StyleCI suggestion 2025-11-12 07:57:30 +01:00
Vizhash16x16Test.php enable strict types in PHP 2024-06-04 07:13:55 +02:00
YourlsProxyTest.php enable tests to pass 2025-09-03 20:13:33 +02:00