Uh oh!
There was an error while loading. Please reload this page.
Fix encoding of sanitized translation strings - #18741
Conversation
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
georgehrke
left a comment
There was a problem hiding this comment.
If I'm not completely mistaken, this will also return stuff like < instead of <, possible allowing injection of HTML.
Since this is used all over the place and not just inside Vue or Handlebar templates, I'm not sure that we can assume that it will later on be escaped.
Or am i wrong here?
rullzer
commented
Jan 8, 2020
Am mmm yes. |
ChristophWurst
commented
Jan 8, 2020
That would only be a problem for the cases where we use jQuery's |
georgehrke
commented
Jan 8, 2020
Yes, and I wouldn't be surprised if in some dark corner of javascript we haven't touched since 2015 we write code to nodes manually. Or I wouldn't rule out that some apps do that, since up until now |
ChristophWurst
commented
Jan 8, 2020
True, but up until #17123 |
georgehrke
commented
Jan 8, 2020
Which most Browsers can deal with, can't they? And returning unescaped ampersands is still less of a threat than not escaping at all. My point is just that this is a pretty severe breaking change and I'm worried about introducing XSSs or other injections. My suggestion would be to keep the current behaviour as default and put the proposed behaviour behind an option |
rullzer
commented
Jan 8, 2020
Or we do it the stupid sumple way for now. just do a replace of |
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
nickvergessen
commented
Jan 8, 2020
This looks very dangerous. I think it should be fixed in the respective place instead? |
ChristophWurst
commented
Jan 8, 2020
Easier said than done as we're talking about translations. You might assume |
Same for |
See nextcloud/server#18741 Signed-off-by: Joas Schilling <coding@schilljs.com>
nickvergessen
commented
Jan 21, 2020
Okay, seems I misunderstood this a bit. I thought this was a misbehaviour of the single instance here and you tried to fix it globally. E.g.: console.info(t('spreed','You: {lastMessage}',{lastMessage: '<3',}))// Before 'You: <3'// After 'You: <3'console.info(t('spreed','You: {lastMessage}',{lastMessage: '<3',},undefined,{escape: false,}))// Before 'You: <3'// After 'You: <3'this worked before, but it doesn't work now anymore. You can see this e.g. in the last message line of talk. I'd very much like to not have to do things like: nextcloud/spreed#2815 |
georgehrke
commented
Jan 26, 2020
Yet another problem caused by DomPurify: nextcloud/calendar#1915 |
georgehrke
commented
Jan 26, 2020
Alternative suggestion:
Everywhere you know that you will use proper escaping (like in vue or handlebar templates), just use the unescaped one and let vue do it. For most vue apps we have, changing to the unescaped version is just a matter of changing one line: |
nickvergessen
commented
Jan 27, 2020
That would work, although from my pov what we would want is: Purify the translations, just not the inserted parameters. |
ChristophWurst
commented
May 12, 2020
I think this is where the evil comes from. We assume that translations are put into HTML as they are. But they might be used in other APIs or put somewhere where escaping is done automatically. Hence the double escaping. IMO the translation helper should only translate. Escaping should be an explicit step. |
ChristophWurst
commented
May 12, 2020
Closing due to lack of progress. None of the proposed solutions were acceptable. |
Fixesnextcloud/calendar#1735
Before
/settings/user/securityshowedDevices & sessions, not it showsDevices & sessionagain.Trick stolen from https://forum.vuejs.org/t/how-to-display-escaped-html-special-characters-the-right-way/33845/5 and https://jsfiddle.net/jamesbrndwgn/3pfmw4cd/1/Edited by @georgehrke:
fixes#18662