Skip to content
Snippets Groups Projects
Commit 95e2df4a authored by Simon Urli's avatar Simon Urli
Browse files

XWIKI-16181: DefaultHTMLDisplayer#getTemplate shouldn't create path with special characters

  * Use a more easy to read replacement path
parent 7b9da2ba
No related branches found
No related tags found
No related merge requests found
......@@ -64,16 +64,6 @@ public class DefaultTemplateHTMLDisplayer implements HTMLDisplayer<Object>
*/
public static final String TEMPLATE_EXTENSION = ".vm";
/**
* A regular expression specifying what are the special characters that have to be replaced in created paths.
*/
private static final String SPECIAL_CHARACTERS_TO_REPLACE = "[<>? ]";
/**
* The replacement character used to clean paths from special characters.
*/
private static final String REPLACEMENT_CHARACTER = ".";
@Inject
protected TemplateManager templateManager;
......@@ -164,7 +154,7 @@ private Template getTemplate(Type type, String mode)
private String cleanPath(String path)
{
return path.replaceAll(SPECIAL_CHARACTERS_TO_REPLACE, REPLACEMENT_CHARACTER);
return path.replaceAll("<", "(").replaceAll(">", ")").replaceAll("\\?", "_").replaceAll(" ", "");
}
private List<String> getTemplatePaths(Type type, String mode)
......
......@@ -123,8 +123,8 @@ public void getTemplateWithNullValueAndSpecialTypeTest() throws Exception
{
this.defaultTemplateHTMLDisplayer.display(new DefaultParameterizedType(null, List.class, Block.class), null);
verify(this.templateManager)
.getTemplate("html_displayer/java.util.list.org.xwiki.rendering.block.block./view.vm");
verify(this.templateManager).getTemplate("html_displayer/java.util.list.org.xwiki.rendering.block.block..vm");
.getTemplate("html_displayer/java.util.list(org.xwiki.rendering.block.block)/view.vm");
verify(this.templateManager).getTemplate("html_displayer/java.util.list(org.xwiki.rendering.block.block).vm");
verify(this.templateManager).getTemplate("html_displayer/view.vm");
verify(this.templateManager).getTemplate("html_displayer/default.vm");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment