PrivateBin/lib
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 apply StyleCI recommendation 2025-10-12 18:40:48 +02:00
Model replaced the term "paste" with the more generic "document" 2025-07-25 08:16:08 +02:00
Persistence ensure PHP opcache gets invalidated, when storing data in file parsed via PHP require 2025-10-12 11:39:58 +02:00
Proxy style: fix indentation 2025-09-03 14:12:12 +00:00
.htaccess updating shipped .htaccess files for Apache 2.4 as per https://httpd.apache.org/docs/2.4/upgrading.html#access - Thanks @EchoDev, fixes #194 2017-03-11 08:56:14 +01:00
Configuration.php Merge branch 'master' into advisory-fix-1 2025-11-11 22:00:09 +01:00
Controller.php incrementing version 2025-11-12 08:00:50 +01:00
Filter.php Switch from binary bytes to SI-units 2025-07-23 21:06:20 +03:00
FormatV2.php pass by reference, closes #858 2025-03-11 08:22:21 +01:00
I18n.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
Json.php pass by reference, closes #858 2025-03-11 08:22:21 +01:00
Model.php enable strict types in PHP 2024-06-04 07:13:55 +02:00
Request.php Added shlink integration 2025-08-15 00:07:51 +01:00
TemplateSwitcher.php ensure template cookie cannot be a path 2025-11-11 17:52:48 +01:00
View.php remove dead code 2025-11-11 17:56:49 +01:00
Vizhash16x16.php address Scrutinizer reported issues 2025-07-19 21:47:18 +02:00