Commit graph

81 commits

Author SHA1 Message Date
El RIDO
4f28c357ae
Merge pull request #1715 from PrivateBin/i18n/soften-html-encoding
fix: do not encode source JSON translation string resulting in wrong display of special characters like '
2025-12-03 19:07:17 +01:00
El RIDO
aa931c7a5c
enable Swedish translations 2025-12-02 06:40:07 +01:00
El RIDO
b4db5f8e57
apply null coalescing operator, strict equality, avoid aliases, prefer empty 2025-11-20 08:19:14 +01:00
El RIDO
0e2055d54a
remove unnecessary variable 2025-11-19 11:15:28 +01:00
El RIDO
3a23117ebf
Refactored translation of exception messages 2025-11-19 09:36:40 +01:00
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
El RIDO
46c49e5455
apply StyleCI recommendation 2025-03-13 09:32:39 +01:00
El RIDO
629f263cf5
pass by reference, closes #858 2025-03-11 08:22:21 +01:00
El RIDO
45b38770db
Merge branch 'master' into keyboard-trap 2025-01-04 08:48:08 +01:00
ribas160
f9e2373e62 - str_starts_with, str_contains used instead of strpos === 0, strpos !== 0, strpos === false, strpos !== false
- symfony/polyfill-php80 installed to introduce the polyfill and support php7.3 using php8 functions
- symfony/polyfill-ctype installed to introduce ctype functions in case somebody doesn't have the ctype extension installed
2025-01-04 00:46:20 +02:00
El RIDO
5aa7a95841
avoid unnecessary indentation 2024-12-27 13:42:16 +01:00
El RIDO
c7195aaf9a
replicate template changes, fix bugs
- fixes QR code height introducing space even when hidden in page layout
- fix modals in bootstrap 5 (modal syntax changed heavily, no longer jQuery integrated)
- hide and show tab-toggle depending on application state
- don't encode HTML entities in translated messages containing kbd tags (in addition to links)
2024-11-24 15:42:38 +01:00
El RIDO
cebc9acce6 enable strict types in PHP 2024-06-04 07:13:55 +02:00
El RIDO
05402ef304 remove version from doc blocs
- @version in file header level isn't used on code docs, it is intended
  for API versions at class or method level
- avoids needing to update all these files on version increment
- avoids needing to regenerate SRI hashes for privatebin.js through
  extra phpunit run
- simplifies VERSION_FILES list
- avoids having to filter above list during loop
- adds a few missing doc bloc headers
2024-05-28 21:03:22 +02:00
El RIDO
22419cd68a
incrementing version 2024-05-13 19:18:30 +02:00
El RIDO
5067e9222c
incrementing version 2024-05-05 20:43:33 +02:00
El RIDO
e1e0e8399c
phpdoc improvements 2024-03-10 18:01:46 +01:00
El RIDO
5f00587d71
phpdoc improvements, fixes #1036 2024-03-10 17:07:10 +01:00
El RIDO
aad975a721
incrementing version 2024-02-11 15:31:11 +01:00
El RIDO
a3ee624d3a
incrementing version 2024-02-11 14:17:27 +01:00
El RIDO
257fc5d2b6
enable Romanian translation and credit it 2024-01-27 19:15:40 +01:00
El RIDO
d49be80ffb
prevent regression around presence or absence of en.json
it gets excluded in the release archive, it's absence should not make
any difference
2023-12-18 21:49:21 +01:00
El RIDO
d0420fb418
1.6.2 release 2023-12-15 07:20:20 +01:00
El RIDO
684924e9e5
apply StyleCI patch 2023-12-09 12:00:57 +01:00
El RIDO
a7f720d825
ensure English is always added to available languages, fixes #1208
bug got introduced in 3668f1e3f4 and
started affecting release after 896a49c8cf
2023-12-09 11:58:29 +01:00
El RIDO
3bd570bd6a
incrementing version 2023-12-04 21:07:17 +01:00
El RIDO
5c97443d1d
add basic RTL support, drop default language key 2023-09-19 07:29:00 +02:00
El RIDO
f56907bd38
increment version 2023-09-11 19:36:45 +02:00
El RIDO
fe37b7f0e5 enable & credit Japanese & Arabic translations 2023-08-01 14:00:45 +02:00
El RIDO
01afe7d481
incrementing version 2023-07-09 08:44:22 +02:00
El RIDO
8988899c8c
apply StyleCI patch, fixes #1084 2023-06-18 12:54:22 +02:00
El RIDO
e84a8694e4
incrementing version 2022-12-24 05:52:07 +01:00
El RIDO
b5602dd1ae
incrementing version 2022-12-11 05:02:15 +01:00
El RIDO
89df4a54ec
enable and credit Thai translation 2022-11-07 07:12:40 +01:00
El RIDO
bff4d3a016
PHP 8.2 compatibility: Use of "self" in callables is deprecated 2022-10-25 07:15:09 +02:00
El RIDO
77409e6065
crediting greek language as well, plus docs 2022-09-29 21:15:00 +02:00
El RIDO
b61b4253a6
enabled use of Slovak translations 2022-09-29 05:34:49 +02:00
El RIDO
f717334ee0
- credit & document Turkish translation
- remove plural indicators
- add plural logic and enable Turkish translation
2022-04-28 20:05:57 +02:00
El RIDO
456ced37c2
incrementing version 2022-04-05 07:30:51 +02:00
El RIDO
f0d0daffcc
enable and credit new Finnish translation 2022-04-05 07:22:07 +02:00
Patriccollu
30c0d22468
Updating I18n.php to add Corsican as new locale 2022-02-24 20:05:19 +01:00
El RIDO
8faf0501f4
improve Lojban support
- Crowdin has to use the 3 letter language code, since Lojban has no 2 letter code. Added support for this in the PHP backend and renamed the translation file.
- Lojban has no plural cases, updated the plural-formulas accordingly.
- Credited the change and documented it.
- Updated the SRI hashes.
2022-02-12 16:17:09 +01:00
El RIDO
175d14224e
set plurals for and credit Estonian translation 2021-04-16 18:27:12 +02:00
El RIDO
458ebcb321
incrementing version 2021-04-05 17:05:14 +02:00
El RIDO
da0896fe42
set plurals for and credit Catalan translation 2021-04-02 09:00:27 +02:00
El RIDO
5a9bcea3a9
set plurals for and credit Indonesian translation 2021-03-09 05:54:06 +01:00
El RIDO
b38ebc503e
plural rules and documenting newly added languages 2021-01-07 21:16:03 +01:00
El RIDO
3668f1e3f4
attempt to accomodate Crowdin by providing a single source translation file that is not actually used or loaded by our code 2020-10-04 12:39:35 +02:00
El RIDO
9914c37683
incrementing version 2020-03-22 06:44:04 +01:00
El RIDO
adece1d784
incrementing version 2020-02-16 11:15:51 +01:00