mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-24 10:16:00 +03:00
Revise quote escaping for translated strings in WebUI
qbt only need to escape double quotes for the sake of HTML attributes. As for single quotes it can leave them as-is since WebUI enforce using double quotes for strings. PR #21180.
This commit is contained in:
parent
9a8572bd21
commit
155fe96bdd
1 changed files with 5 additions and 3 deletions
|
@ -265,9 +265,11 @@ void WebApplication::translateDocument(QString &data) const
|
|||
// it should fallback to `sourceText`
|
||||
QString translation = loadedText.isEmpty() ? sourceText : loadedText;
|
||||
|
||||
// Use HTML code for quotes to prevent issues with JS
|
||||
translation.replace(u'\'', u"'"_s);
|
||||
translation.replace(u'\"', u"""_s);
|
||||
// Escape quotes to workaround issues with HTML attributes
|
||||
// FIXME: this is a dirty workaround to deal with broken translation strings:
|
||||
// 1. Translation strings is the culprit of the issue, they should be fixed instead
|
||||
// 2. The escaped quote/string is wrong for JS. JS use backslash to escape the quote: "\""
|
||||
translation.replace(u'"', u"""_s);
|
||||
|
||||
data.replace(i, regexMatch.capturedLength(), translation);
|
||||
i += translation.length();
|
||||
|
|
Loading…
Reference in a new issue