Problem The content of wiki skin files (the content property of XWiki.XWikiSkinFileOverrideClass objects, and the style.css, header.vm, footer.vm, viewheader.vm, view.vm and edit.vm properties of XWiki.XWikiSkins objects) gets corrupted whenever some code processes the wiki content of the document's xobjects: the whole file is parsed as xwiki/2.1 and rendered back as xwiki/2.1, which breaks the Velocity/CSS code and thus the skin. For example, the standard htmlheader.vm lines:
## ---------------------------------------------------------------------------------------------------------------
## Ensure that the Content-Type meta directive is the first one in the header.
## See http: ## ---------------------------------------------------------------------------------------------------------------
<meta http-equiv="Content-Type" content="text/html; charset=$xwiki.encoding" />
## ---------------------------------------------------------------------------------------------------------------
## Compute the title.
## ---------------------------------------------------------------------------------------------------------------
become:
## ---
--##-- Ensure that the Content-Type meta directive is the first one in the header.
## See http: ## ---
<meta http-equiv="Content-Type" content="text/html; charset=$xwiki.encoding" />
## ---
--##-- Compute the title.
## ##--##-
(other lines get merged, e.g. ...action")##, or ## ##). Steps to reproduce
- Create a page Sandbox.ReproTarget
- Create a page Sandbox.SkinRepro with an XWiki.XWikiSkinFileOverrideClass object having path = htmlheader.vm and content = the standard htmlheader.vm template plus the line ## Help: [[Sandbox.ReproTarget]]
- Rename Sandbox.ReproTarget (keeping the default "update links" option)
Expected: the skin file is left untouched (it's Velocity code, not wiki content). Actual: Sandbox.SkinRepro gets a new version with the comment "Renamed back-links." and its content is corrupted as shown above. Another way to reproduce: install the org.xwiki.contrib:listener-urlnormalizer-api extension and save a skin file override whose content contains an absolute URL pointing to the wiki itself: the content is corrupted on save. Cause These properties are created by BaseClass#addTemplateField(), which sets the PureText editor but no content type. An empty content type means "wiki text" (TextAreaClass#getContentType()), so TextAreaClass#isWikiContent() returns true for them and any code handling the wiki content of xobjects (link indexing, link refactoring on rename/move, syntax conversion, extensions such as the URL normalizer) treats skin files as wiki content. Workaround In the class editor of XWiki.XWikiSkinFileOverrideClass (and XWiki.XWikiSkins), set the "Content Type" of these properties to "Plain Text". |