Skip to content

Commit

Permalink
XWIKI-20276: Improve escaping in the timezone displayer
Browse files Browse the repository at this point in the history
  • Loading branch information
mflorea committed Feb 8, 2023
1 parent eb174d5 commit d11ca5d
Show file tree
Hide file tree
Showing 17 changed files with 373 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@
#else
#set ($output = $doc.display($property))
#end
#set ($output = $stringtool.removeStart($output, '{{html clean="false" wiki="false"}}'))
#set ($output = $stringtool.removeEnd($output, '{{/html}}'))
$output
#unwrapXPropertyDisplay($output)
#end

#macro (displayPathsPropertyValue $property)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,7 @@
## the annotated document (i.e. isolated), not the current document.
#set ($output = $annotatedDocument.display($annotationProperty.name, 'view', $annotationObject))
## Remove the HTML macro wrapping because the output is later injected in another HTML macro with wiki=false.
#set ($output = $stringtool.removeStart($output, '{{html clean="false" wiki="false"}}'))
#set ($output = $stringtool.removeEnd($output, '{{/html}}'))
$output
#unwrapXPropertyDisplay($output)
#end
#end
{{/velocity}}</content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,7 @@
#end

#macro (displayCKEditorConfigPropertyValue $configDoc $propName $action)
#set ($output = $configDoc.display($propName, $action))
#set ($output = $stringtool.removeStart($output, '{{html clean="false" wiki="false"}}'))
#set ($output = $stringtool.removeEnd($output, '{{/html}}'))
$output
#unwrapXPropertyDisplay($configDoc.display($propName, $action))
#end

#macro (displayCKEditorConfig $configDoc $action)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@
#end

#macro (displayPDFExportConfigPropertyValue $configProperty $displayMode)
#set ($output = $doc.display($configProperty.name, $displayMode))
#set ($output = $stringtool.removeStart($output, '{{html clean="false" wiki="false"}}'))
#set ($output = $stringtool.removeEnd($output, '{{/html}}'))
$!output
#unwrapXPropertyDisplay($doc.display($configProperty.name, $displayMode))
#end

#macro (viewPDFExportConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@
#end

#macro (renderPDFElement $pdfTemplateObj $element)
#set ($output = $tdoc.display($element, $pdfTemplateObj))
#set ($output = $stringtool.removeStart($output, '{{html clean="false" wiki="false"}}'))
#set ($output = $stringtool.removeEnd($output, '{{/html}}'))
$!output
#unwrapXPropertyDisplay($tdoc.display($element, $pdfTemplateObj))
#end

#macro (renderPDFContent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@
#else
#set($fieldValue = "$!fieldProperty.getValue()")
#end
#set($fieldDisplayValue = "$!itemDoc.display($colname, 'view')")
#set($fieldDisplayValue = "#unwrapXPropertyDisplay($itemDoc.display($colname, 'view'))")
#if($fieldDisplayValue == '')
#set($fieldDisplayValue = $services.localization.render("${request.transprefix}emptyvalue"))
#end
Expand All @@ -514,7 +514,7 @@
#set($fieldUrl = '')
#end
#end
#set($discard = $row.put($colname, $fieldDisplayValue.replaceFirst($regextool.quote('{{html clean="false" wiki="false"}}'), '').replaceAll("$regextool.quote('{{/html}}')$", '')))
#set($discard = $row.put($colname, $fieldDisplayValue))
#set($discard = $row.put("${colname}_value", $fieldValue))
#set($discard = $row.put("${colname}_url", $fieldUrl))
## Reset to the default class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@

{{velocity output="false"}}
#macro (displayConfigPropertyValue $propName $action)
#set ($output = $doc.display($propName, $action))
#set ($output = $stringtool.removeStart($output, '{{html clean="false" wiki="false"}}'))
#set ($output = $stringtool.removeEnd($output, '{{/html}}'))
$output
#unwrapXPropertyDisplay($doc.display($propName, $action))
#end

#macro (displayPageLayoutSection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@

{{velocity output="false"}}
#macro (displayObjectPropertyValue $propertyName $mode)
#set ($output = $doc.display($propertyName, $mode))
#set ($output = $stringtool.removeStart($output, '{{html clean="false" wiki="false"}}'))
#set ($output = $stringtool.removeEnd($output, '{{/html}}'))
$output
#unwrapXPropertyDisplay($doc.display($propertyName, $mode))
#end

#macro (displaySearchSuggestSource $source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,25 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>test-jar</id>
<goals>
<goal>test-jar</goal>
</goals>
<configuration>
<includes>
<include>**/UIExtensionScriptServiceComponentList.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.uiextension.script;

import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import org.xwiki.component.wiki.internal.DefaultWikiComponentManager;
import org.xwiki.component.wiki.internal.DefaultWikiComponentManagerContext;
import org.xwiki.component.wiki.internal.WikiComponentManagerEventListenerHelper;
import org.xwiki.component.wiki.internal.bridge.DefaultContentParser;
import org.xwiki.component.wiki.internal.bridge.DefaultWikiObjectComponentManagerEventListener;
import org.xwiki.component.wiki.internal.bridge.WikiObjectComponentManagerEventListenerProxy;
import org.xwiki.rendering.async.internal.block.DefaultBlockAsyncRenderer;
import org.xwiki.test.annotation.ComponentList;
import org.xwiki.uiextension.internal.DefaultUIExtensionManager;
import org.xwiki.uiextension.internal.WikiUIExtensionComponentBuilder;
import org.xwiki.uiextension.internal.filter.ExcludeFilter;
import org.xwiki.uiextension.internal.filter.SelectFilter;
import org.xwiki.uiextension.internal.filter.SortByCustomOrderFilter;
import org.xwiki.uiextension.internal.filter.SortByIdFilter;
import org.xwiki.uiextension.internal.filter.SortByParameterFilter;

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* Pack of default component implementations that are needed for {@link UIExtensionScriptService}.
*
* @version $Id$
* @since 14.10.5
* @since 15.1RC1
*/
@Documented
@Retention(RUNTIME)
@Target({TYPE, METHOD, ANNOTATION_TYPE})
@ComponentList({
UIExtensionScriptService.class,
DefaultUIExtensionManager.class,
WikiUIExtensionComponentBuilder.class,
// Filters
ExcludeFilter.class,
SelectFilter.class,
SortByCustomOrderFilter.class,
SortByIdFilter.class,
SortByParameterFilter.class,
// Needed for registering the UI extensions defined in wiki pages.
DefaultWikiObjectComponentManagerEventListener.class,
WikiObjectComponentManagerEventListenerProxy.class,
WikiComponentManagerEventListenerHelper.class,
DefaultWikiComponentManager.class,
DefaultWikiComponentManagerContext.class,
// Needed for rendering the UI extensions.
DefaultContentParser.class,
DefaultBlockAsyncRenderer.class
})
@Inherited
public @interface UIExtensionScriptServiceComponentList
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@
#macro (displayProperty $propertyName $object $action)
#set ($propertyClass = $object.xWikiClass.get($propertyName))
#set ($isCheckbox = $propertyClass.getValue('displayFormType') == 'checkbox')
#set ($fieldDisplay = $stringtool.removeEnd($stringtool.removeStart($object.display($propertyName, $action),
'{{html clean="false" wiki="false"}}'), '{{/html}}'))
#set ($fieldDisplay = "#unwrapXPropertyDisplay($object.display($propertyName, $action))")
&lt;dt&gt;
&lt;label #if ($action == 'edit' &amp;&amp; !$isCheckbox)
for="$escapetool.xml("${object.xWikiClass.name}_${object.number}_$propertyName")"#end&gt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,42 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<!-- Test dependencies. -->
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-test-page</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-web-templates</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<!-- Provides the component list for UIExtensionScriptService. -->
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-uiextension-api</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<!-- Provides the component list for RenderingScriptService. -->
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-rendering-xwiki</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-rendering-configuration-default</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit d11ca5d

Please sign in to comment.