Skip to content

Commit 7bf7094

Browse files
committed
XWIKI-20268: Improve escaping in AdminTemplatesSheet
1 parent 07af26f commit 7bf7094

File tree

2 files changed

+25
-1
lines changed
  • xwiki-platform-core/xwiki-platform-administration
    • xwiki-platform-administration-test/xwiki-platform-administration-test-docker/src/test/it/org/xwiki/administration/test/ui
    • xwiki-platform-administration-ui/src/main/resources/XWiki

2 files changed

+25
-1
lines changed

xwiki-platform-core/xwiki-platform-administration/xwiki-platform-administration-test/xwiki-platform-administration-test-docker/src/test/it/org/xwiki/administration/test/ui/PageTemplatesIT.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.junit.jupiter.api.BeforeEach;
2626
import org.junit.jupiter.api.Order;
2727
import org.junit.jupiter.api.Test;
28+
import org.openqa.selenium.WebElement;
2829
import org.xwiki.administration.test.po.TemplateProviderInlinePage;
2930
import org.xwiki.administration.test.po.TemplatesAdministrationSectionPage;
3031
import org.xwiki.model.reference.DocumentReference;
@@ -358,6 +359,29 @@ void createPageFromForbiddenTemplate(TestUtils setup, TestReference testReferenc
358359
assertEquals("Some content in that page", viewPage.getContent());
359360
}
360361

362+
/**
363+
* The goal of this test is to check that the template provider's title is correctly escaped.
364+
*/
365+
@Test
366+
@Order(5)
367+
void templateProviderTitleEscaping(TestUtils setup, TestReference testReference) throws Exception
368+
{
369+
cleanUp(setup, testReference);
370+
371+
// Create a template
372+
String templateContent = "Templates are fun";
373+
String providerName = "{{html}}<span>HTML</span>{{/html}}";
374+
LocalDocumentReference templateProviderReference = new LocalDocumentReference(providerName,
375+
testReference.getLocalDocumentReference().getParent());
376+
createTemplateAndTemplateProvider(setup, templateProviderReference, templateContent,
377+
"Funny templates", true);
378+
379+
TemplatesAdministrationSectionPage adminPage = TemplatesAdministrationSectionPage.gotoPage();
380+
List<WebElement> links = adminPage.getExistingTemplatesLinks();
381+
assertFalse(links.stream().anyMatch(element -> element.getText().equals("HTML")));
382+
assertTrue(links.stream().anyMatch(element -> providerName.equals(element.getText())));
383+
}
384+
361385
/**
362386
* Helper function to Create both a Template and a Template Provider for the tests in this class.
363387
*/

xwiki-platform-core/xwiki-platform-administration/xwiki-platform-administration-ui/src/main/resources/XWiki/AdminTemplatesSheet.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
== {{translation key="admin.templates.providerslist"/}} ==
113113

114114
#foreach($providerFullname in $availableProviders)
115-
* [[$services.rendering.escape($xwiki.getDocument($providerFullname).plainTitle, $xwiki.currentContentSyntaxId)&gt;&gt;$providerFullname]]
115+
* [[$services.rendering.escape($services.rendering.escape($xwiki.getDocument($providerFullname).plainTitle, $xwiki.currentContentSyntaxId), $xwiki.currentContentSyntaxId)&gt;&gt;$services.rendering.escape($providerFullname, $xwiki.currentContentSyntaxId)]]
116116
#end
117117
)))
118118
#end

0 commit comments

Comments
 (0)