This issue has been created
There is 1 update.
 
 
XWiki Platform / cid:jira-generated-image-avatar-81748322-3105-4fe0-a465-64484c45ec81 XWIKI-24010 Open

Inconsistent escapes in the $services.localization.render method

 
View issue   ·   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-e2a91e28-c378-4c0b-b5cf-f2ab18d2b03e Brassat Alexandru created this issue on 12/Feb/26 13:58
 
Summary: Inconsistent escapes in the $services.localization.render method
Issue Type: cid:jira-generated-image-avatar-81748322-3105-4fe0-a465-64484c45ec81 Bug
Affects Versions: 17.10.2
Assignee: Unassigned
Components: Localization
Created: 12/Feb/26 13:58
Priority: cid:jira-generated-image-static-minor-9dabab85-b5be-4922-a9f9-484e3816134f Minor
Reporter: Brassat Alexandru
Description:

There are some utility $services.localization.render(...) which are rarely used, and which also perform syntax escapes. The resulting string differs from the behavior of $services.rendering.escape(string, syntax), and I'm not sure if it is intended that the behaviors are different.

Example:

 

##translationKey=Test"> <script class="xss">alert('hi!')</script> [[link]] <span data-attr="全
#set ($translationKey = 'translationKey')
$services.localization.render('translationKey')
## Result: Test"> <script class="xss">alert('hi!')</script> [[link]] <span data-attr="全
loc: $services.localization.render('translationKey', 'xwiki/2.1', [])
## Result: Calendar Default"> <script class="xss">alert('hi!')</script> ~[~[link]] <span data-attr="全
render/loc: $services.rendering.escape($services.localization.render('translationKey'), 'xwiki/2.1')
## Result: ~C~a~l~e~n~d~a~r~ ~D~e~f~a~u~l~t~"~>~ ~<~s~c~r~i~p~t~ ~c~l~a~s~s~=~"~x~s~s~"~>~a~l~e~r~t~(~'~h~i~!~'~)~<~/~s~c~r~i~p~t~>~ ~[~[~l~i~n~k~]~]~ ~<~s~p~a~n~ ~d~a~t~a~-~a~t~t~r~=~"~全

 

I don't think this is a big issue, as my primary motive for discovering this was trying to get shorter velocity code for escapes.

I would have expected that $services.rendering.escape($services.localization.render('translationKey'), 'xwiki/2.1') and $services.localization.render('translationKey', 'xwiki/2.1', []) are equivalent, but I'm not sure if that was a good assumption. (Feel free to close this issue if this behavior is expected)

 
 

1 update

 
cid:jira-generated-image-avatar-e2a91e28-c378-4c0b-b5cf-f2ab18d2b03e Changes by Brassat Alexandru on 12/Feb/26 13:58
 
Description: There are some utility $services.localization.render(...) which are [rarely used|https://github.com/search?q=owner%3Axwikisas+%2F%5C%24services%5C.localization%5C.render%5C%28.*%2C+%5C%27xwiki%5C%2F2%5C.1%5C%27%2C+%5C%5B.*%5C%5D%5C%29%2F&type=code], and which also perform syntax escapes. The resulting string differs from the behavior of $services.rendering.escape(string, syntax), and I'm not sure if it is intended that the behaviors are different.

Example:

 
{code:java}
##translationKey=Test"> <script class="xss">alert('hi!')</script> [[link]] <span data-attr="全
#set ( $ translationKey = 'translationKey')
$
services.localization.render('translationKey')
## Result: Test"> <script class="xss">alert('hi!')</script> [[link]] <span data-attr="全
loc: $services.localization.render('translationKey', 'xwiki/2.1', [])
## Result:
Calendar Default Test "> <script class="xss">alert('hi!')</script> ~[~[link]] <span data-attr="全
render/loc: $services.rendering.escape($services.localization.render('translationKey'), 'xwiki/2.1')
## Result: ~
C T ~ a~l~ e~ n s ~ d~a~r~ ~D~e~f~a~u~l~ t~"~>~ ~<~s~c~r~i~p~t~ ~c~l~a~s~s~=~"~x~s~s~"~>~a~l~e~r~t~(~'~h~i~!~'~)~<~/~s~c~r~i~p~t~>~ ~[~[~l~i~n~k~]~]~ ~<~s~p~a~n~ ~d~a~t~a~-~a~t~t~r~=~"~全{code}
 

I don't think this is a big issue, as my primary motive for discovering this was trying to get shorter velocity code for escapes.

I would have expected that $services.rendering.escape($services.localization.render('translationKey'), 'xwiki/2.1') and $services.localization.render('translationKey', 'xwiki/2.1', []) are equivalent, but I'm not sure if that was a good assumption. (Feel free to close this issue if this behavior is expected)