On Thu, Mar 4, 2010 at 13:56, Sergiu Dumitriu <sergiu(a)xwiki.com> wrote:
On 03/04/2010 10:54 AM, Thomas Mortagne wrote:
On Wed, Mar 3, 2010 at 13:48, sdumitriu
<platform-notifications(a)xwiki.org> wrote:
Author: sdumitriu
Date: 2010-03-03 13:48:22 +0100 (Wed, 03 Mar 2010)
New Revision: 27429
Modified:
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/Utils.java
Log:
XWIKI-4955: Page with empty content leads to "This template does not exist"
message when viewed in plain mode
Revert the trim() removal, which makes all the validation tests fail
Then the wrong template should be fixed instead of putting a hack...
It is not a hack, and there is not one wrong template. All the templates
There is 16 wrong templates plus macro template itself is wrong and
for most of them it's just one line that needs ##.
generate whitespaces. I still believe that there is
absolutely no reason
A template don't have to generate white spaces and the issue are not
all templates that generated whites spaces, we just need to fix
templates that generate white space before the actual xhtml content
(i.e. before "<?xml..." in htmlheader.vm),
not to use the trim(), since nobody cares if the
whitespace reaches the
The problem is that you only think about full xhtml content, in that
case yes we don't care about triming that content but that's not our
only use case. You could write templates that return some content you
want to get exactly like it was. An example: you need to write a
service in a document to return the exact content of an object or the
content of the document, with this you will be forced to inject
directly your content in the response object and use
$context.setFinished(true) which is a pain.
It's a hack because at Utils level we have no idea what is the
content, safest is to let user decide how he want to use the content
he produced, you can say you don't care as much as you want i still
don't see how we could decide that noone is allowed to take white
space as meaningful content...
If the goal is to protect against UI templates badly written we should
limit this trim() only to xhtml or html MIME types.
client or not. If you don't agree, feel free to
hunt all the whitespace
in the templates, including those in custom skins that duplicate the
templates.
>
> Modified: platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/Utils.java
> ===================================================================
> --- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/Utils.java
2010-03-03 12:44:52 UTC (rev 27428)
> +++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/Utils.java
2010-03-03 12:48:22 UTC (rev 27429)
> @@ -155,7 +155,7 @@
> // Replace all placeholders with the protected values
> content = replacePlaceholders(content, context);
> disablePlaceholders(context);
> - content = context.getWiki().getPluginManager().endParsing(content,
context);
> + content =
context.getWiki().getPluginManager().endParsing(content.trim(), context);
> } catch (IOException e) {
> if (LOG.isDebugEnabled()) {
> LOG.debug("IOException while evaluating template [" +
template + "] from /templates/", e);
>
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
--
Thomas Mortagne