This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch maven-fluido-skin-1.x-backports
in repository https://gitbox.apache.org/repos/asf/maven-fluido-skin.git

commit fd9065d6106df5f2d22b1666bb8c0806a75fb1ba
Author: Michael Osipov <[email protected]>
AuthorDate: Thu Mar 30 12:08:36 2023 +0200

    [MSKINS-222] Template does not properly escape reserved XML chars
    
    This closes #50
---
 src/it/mskins-222/pom.xml                        | 73 ++++++++++++++++++++++++
 src/it/mskins-222/src/site/apt/index.apt.vm      | 34 +++++++++++
 src/it/mskins-222/src/site/site.xml              | 62 ++++++++++++++++++++
 src/it/mskins-72/verify.groovy                   |  2 +-
 src/main/resources/META-INF/maven/site-macros.vm | 65 ++++++++++-----------
 src/main/resources/META-INF/maven/site.vm        | 12 ++--
 6 files changed, 209 insertions(+), 39 deletions(-)

diff --git a/src/it/mskins-222/pom.xml b/src/it/mskins-222/pom.xml
new file mode 100644
index 0000000..7741497
--- /dev/null
+++ b/src/it/mskins-222/pom.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.skins</groupId>
+    <artifactId>maven-skins</artifactId>
+    <version>@project.parent.version@</version>
+  </parent>
+
+  <groupId>org.apache.maven.skins.its</groupId>
+  <artifactId>mskins-222</artifactId>
+  <version>@project.version@</version>
+
+  <name>@project.name@ IT, &lt;MSKINS-222&gt;</name>
+  <url>https://maven.apache.org/skins/@project.artifactId@/mskins-222/</url>
+
+  <description>
+    Escaping reversed XML chars
+  </description>
+
+  <properties>
+    <skinName>@project.name@</skinName>
+    <skinDescription>@project.description@</skinDescription>
+    <skinGroupId>@project.groupId@</skinGroupId>
+    <skinArtifactId>@project.artifactId@</skinArtifactId>
+    <skinVersion>@project.version@</skinVersion>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-site-plugin</artifactId>
+        <version>@sitePluginVersion@</version>
+      </plugin>
+    </plugins>
+  </build>
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-project-info-reports-plugin</artifactId>
+        <version>@projectInfoReportsPluginVersion@</version>
+        <reportSets>
+          <reportSet>
+            <reports>
+              <report>index</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+    </plugins>
+  </reporting>
+
+</project>
diff --git a/src/it/mskins-222/src/site/apt/index.apt.vm 
b/src/it/mskins-222/src/site/apt/index.apt.vm
new file mode 100644
index 0000000..baebf7d
--- /dev/null
+++ b/src/it/mskins-222/src/site/apt/index.apt.vm
@@ -0,0 +1,34 @@
+ ------
+ ${project.name}
+ ------
+ Tom & Jerry
+ "Jack the Stripper"
+ Michael Osipov \<[email protected]\>
+ ------
+ 2023-04-01
+ ------
+
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements.  See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership.  The ASF licenses this file
+~~ to you under the Apache License, Version 2.0 (the
+~~ "License"); you may not use this file except in compliance
+~~ with the License.  You may obtain a copy of the License at
+~~
+~~   http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing,
+~~ software distributed under the License is distributed on an
+~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~ KIND, either express or implied.  See the License for the
+~~ specific language governing permissions and limitations
+~~ under the License.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+${project.name}
+
+ This is a test for reserved XML char escaping.
+
diff --git a/src/it/mskins-222/src/site/site.xml 
b/src/it/mskins-222/src/site/site.xml
new file mode 100644
index 0000000..bcc1f40
--- /dev/null
+++ b/src/it/mskins-222/src/site/site.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ -->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.1.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 
http://maven.apache.org/xsd/decoration-1.1.0.xsd";
+  name="${skinName}">
+
+  <skin>
+    <groupId>${skinGroupId}</groupId>
+    <artifactId>${skinArtifactId}</artifactId>
+    <version>${skinVersion}</version>
+  </skin>
+
+  <bannerLeft>
+    <name>Banner &quot;left&quot; &lt;name&gt;</name>
+    <alt>Banner &quot;left&quot; &lt;alt&gt;</alt>
+    <title>Banner &quot;left&quot; &lt;title&gt;</title>
+  </bannerLeft>
+  <bannerRight>
+    <name>Banner &quot;right&quot; &lt;name&gt;</name>
+    <alt>Banner &quot;right&quot; &lt;alt&gt;</alt>
+    <title>Banner &quot;right&quot; &lt;title&gt;</title>
+  </bannerRight>
+
+  <poweredBy>
+    <logo name="&lt;Powered by&gt; &quot;logo&quot; &apos;@name&apos;" 
alt="&lt;Powered by&gt; &quot;logo&quot; &apos;@alt&apos;" title="&lt;Powered 
by&gt; &quot;logo&quot; &apos;@title&apos;" />
+  </poweredBy>
+
+  <body>
+    <links>
+      <item name="&lt;Links&gt; &quot;item&quot; &apos;@name&apos;" 
alt="&lt;Links&gt; &quot;item&quot; &apos;@alt&apos;" title="&lt;Links&gt; 
&quot;item&quot; &apos;@title&apos;" />
+    </links>
+    <breadcrumbs>
+      <item name="&lt;Breadcrumbs&gt; &quot;item&quot; &apos;@name&apos;" 
alt="&lt;Breadcrumbs&gt; &quot;item&quot; &apos;@alt&apos;" 
title="&lt;Breadcrumbs&gt; &quot;item&quot; &apos;@title&apos;" />
+   </breadcrumbs>
+
+    <menu name="&lt;Menu&gt; &apos;@name&apos;" alt="&lt;Menu&gt; 
&apos;@alt&apos;" title="&lt;Menu&gt; &apos;@title&apos;">
+      <item name="&lt;Menu&gt; &quot;item&quot; &apos;@name&apos;" 
alt="&lt;Menu&gt; &quot;item&quot; &apos;@alt&apos;" title="&lt;Menu&gt; 
&quot;item&quot; &apos;@title&apos;" />
+    </menu>
+  </body>
+
+</project>
diff --git a/src/it/mskins-72/verify.groovy b/src/it/mskins-72/verify.groovy
index 1b663b5..b2e0c0f 100644
--- a/src/it/mskins-72/verify.groovy
+++ b/src/it/mskins-72/verify.groovy
@@ -21,4 +21,4 @@ File index = new File( basedir, "target/site/index.html" )
 int inceptionYear = 2002
 int currentYear = Calendar.getInstance().get(Calendar.YEAR)
 assert index.exists()
-assert index.text.contains( "<p class=\"pull-right\">&#169;" )
+assert index.getText("UTF-8").contains( "<p class=\"pull-right\">\u00A9" )
diff --git a/src/main/resources/META-INF/maven/site-macros.vm 
b/src/main/resources/META-INF/maven/site-macros.vm
index a0890d6..499df79 100644
--- a/src/main/resources/META-INF/maven/site-macros.vm
+++ b/src/main/resources/META-INF/maven/site-macros.vm
@@ -19,7 +19,7 @@
 #**##foreach( $menu in $menus )
 #**##if ( $menu.name )
       <li class="dropdown">
-        <a class="dropdown-toggle" data-toggle="dropdown">$menu.name <b 
class="caret"></b></a>
+        <a class="dropdown-toggle" data-toggle="dropdown">$esc.xml( $menu.name 
) <b class="caret"></b></a>
         <ul class="dropdown-menu">
 #*    *##foreach( $item in $menu.items )
 #*      *##if ( $item.items.size() > 0 )
@@ -49,16 +49,16 @@
 #end
 ##
 #macro ( topLink $href $name $target )
-#**##set ( $linkTitle = ' title="' + $name + '"' )
+#**##set ( $linkTitle = ' title="' + $esc.xml( $name ) + '"' )
 #**##if( $target )
 #*  *##set ( $linkTarget = ' target="' + $target + '"' )
 #**##else
 #*  *##set ( $linkTarget = "" )
 #**##end
 #**##if ( $alignedFileName == $href )
-#*  *#<a title="$name">$name</a>##
+#*  *#<a$linkTitle>$esc.xml( $name )</a>##
 #**##else
-#*  *#<a href="$href"$linkTarget title="$name">$name</a>##
+#*  *#<a href="$href"$linkTarget$linkTitle>$esc.xml( $name )</a>##
 #**##end
 #end
 ##
@@ -73,7 +73,7 @@
 #end
 ##
 #macro ( link $href $name $target $img $position $alt $border $width $height 
$icon )
-#**##set ( $linkTitle = ' title="' + $name + '"' )
+#**##set ( $linkTitle = ' title="' + $esc.xml( $name ) + '"' )
 #**##if( $target )
 #*  *##set ( $linkTarget = ' target="' + $target + '"' )
 #**##else
@@ -93,14 +93,14 @@
 #*  *##if ( $position == "left" )
 #*    *#<a$href$linkClass$linkTarget$linkTitle>#image( $img $alt $border 
$width $height )$name</a>##
 #*  *##else
-#*    *#<a$href$linkClass$linkTarget$linkTitle>$name #image( $img $alt $border 
$width $height )</a>##
+#*    *#<a$href$linkClass$linkTarget$linkTitle>$esc.xml( $name ) #image( $img 
$alt $border $width $height )</a>##
 #*  *##end
 #**##else
 #*  *#<a$href$linkClass$linkTarget$linkTitle>##
 #*  *##if( $icon )
 #*    *#<span class="$icon"></span>##
 #*  *##end
-#*  *#$name</a>##
+#*  *#$esc.xml( $name )</a>##
 #**##end
 #end
 ##
@@ -114,7 +114,7 @@
 #*    *##set ( $imgSrc = ' src="' + $img + '"' )
 #*  *##end
 #*  *##if( $alt )
-#*    *##set ( $imgAlt = ' alt="' + $alt + '"' )
+#*    *##set ( $imgAlt = ' alt="' + $esc.xml( $alt ) + '"' )
 #*  *##else
 #*    *##set ( $imgAlt = ' alt=""' )
 #*  *##end
@@ -148,7 +148,7 @@
 #*        *##set ( $hrf = './' )
 #*      *##end
 #*    *##end
-#*    *#<a href="$hrf" id="$id"#if( $banner.alt ) title="$banner.alt"#end>##
+#*    *#<a href="$hrf" id="$id"#if( $banner.alt ) title="$esc.xml( $banner.alt 
)"#end>##
 #*  *##else
 #*    *#<div id="$id">##
 #*  *##end
@@ -160,9 +160,9 @@
 #*      *##set ( $src = $src.replaceAll( '\\', '/' ) )
 #*    *##end
 #*    *##if ( $banner.alt )
-#*      *##set ( $alt = ' alt="' + $banner.alt + '"' )
+#*      *##set ( $alt = ' alt="' + $esc.xml( $banner.alt ) + '"' )
 #*    *##elseif ( $banner.name )
-#*      *##set ( $alt = ' alt="' + $banner.name + '"' )
+#*      *##set ( $alt = ' alt="' + $esc.xml( $banner.name ) + '"' )
 #*    *##else
 #*      *##set ( $alt = ' alt=""' )
 #*    *##end
@@ -182,13 +182,13 @@
 #*      *##set ( $imgHeight = "" )
 #*    *##end
 #*    *##if( $banner.title )
-#*      *##set ( $bannerTitle=' title="' + $banner.title + '"' )
+#*      *##set ( $bannerTitle=' title="' + $esc.xml( $banner.title ) + '"' )
 #*    *##else
 #*      *##set ( $bannerTitle="" )
 #*    *##end
 #*    *#<img src="$src" $alt$bannerTitle style="$imgBorder$imgWidth$imgHeight" 
/>##
 #*  *##else
-#*    *#<h1>$banner.name</h1>
+#*    *#<h1>$esc.xml( $banner.name )</h1>
 #*  *##end
 ##
 #*  *##if( $banner.href )
@@ -243,9 +243,10 @@
 #*  *##set ( $edit = ' <a href="' + $docRenderingContext.getDoxiaSourcePath( 
$decoration.edit ) + '"><img src="' + $relativePath + 
'/images/accessories-text-editor.png" title="Edit" /></a>' )
 #**##end
 #**##if ( $shortTitle )
-    <li class="active $cssClass">$shortTitle$!edit</li>
+    <li class="active $cssClass">$esc.xml( $shortTitle )$!edit</li>
 #**##else
-    <li class="active $cssClass">$title$!edit</li>
+#* TODO $title can be empty! *#
+    <li class="active $cssClass">$esc.xml( $title )$!edit</li>
 #**##end
 #end
 ##
@@ -294,20 +295,20 @@ $indent    <li>##
 #**##if ( $item.img )
 #*  *##if ( $item.position == "left" )
 #*    *##if ( $alignedFileName == $currentItemHref )
-#*      *#<a>#image( $item.img $item.alt $item.border $item.width $item.height 
) $item.name</a>##
+#*      *#<a>#image( $item.img $item.alt $item.border $item.width $item.height 
) $esc.xml( $item.name )</a>##
 #*    *##else
 #*      *##link( $currentItemHref $item.name $item.target $item.img 
$item.position $item.alt $item.border $item.width $item.height false )
 #*    *##end
 #*  *##else
 #*    *##if ( $alignedFileName == $currentItemHref )
-#*      *#<a>$item.name #image( $item.img $item.alt $item.border $item.width 
$item.height )</a>##
+#*      *#<a>$esc.xml( $item.name ) #image( $item.img $item.alt $item.border 
$item.width $item.height )</a>##
 #*    *##else
 #*      *##link( $currentItemHref $item.name $item.target $item.img 
$item.position $item.alt $item.border $item.width $item.height false )
 #*    *##end
 #*  *##end
 #**##else
 #*  *##if ( $alignedFileName == $currentItemHref )
-#*    *#<a><span class="$collapseClass"></span>$item.name</a>##
+#*    *#<a><span class="$collapseClass"></span>$esc.xml( $item.name )</a>##
 #*  *##else
 #*    *##link( $currentItemHref $item.name $item.target $item.img 
$item.position $item.alt $item.border $item.width $item.height $collapseClass )
 #*  *##end
@@ -345,9 +346,9 @@ $indent     </ul>##
 #*    *##end
 ##
 #*    *##if( $menu.alt )
-#*      *##set ( $alt = ' alt="' + $menu.alt + '"' )
+#*      *##set ( $alt = ' alt="' + $esc.xml( $menu.alt ) + '"' )
 #*    *##else
-#*      *##set ( $alt = ' alt="' + $menu.name + '"' )
+#*      *##set ( $alt = ' alt="' + $esc.xml( $menu.name ) + '"' )
 #*    *##end
 ##
 #*    *##if( $menu.border )
@@ -370,12 +371,12 @@ $indent     </ul>##
 #*    *##set ( $img = '<img class="imageLink"' + $src + $alt + ' style="' + 
$border + $width + $height + '" />' )
 ##
 #*    *##if ( $position == "left" )
-   <li class="nav-header">$img $menu.name</li>
+   <li class="nav-header">$img $esc.xml( $menu.name )</li>
 #*    *##else
-   <li class="nav-header">$menu.name $img</li>
+   <li class="nav-header">$esc.xml( $menu.name ) $img</li>
 #*    *##end
 #*  *##else
-   <li class="nav-header">$menu.name</li>
+   <li class="nav-header">$esc.xml( $menu.name )</li>
 #*  *##end
 #**##end
 #**##if ( $menu.items && $menu.items.size() > 0 )
@@ -392,16 +393,16 @@ $indent     </ul>##
 #*  *##set ( $currentYear = ${date.year} )
 ##
 #*  *##if ( ${project.inceptionYear} && ( ${project.inceptionYear} != 
${currentYear.toString()} ) )
-      ${project.inceptionYear}&#x2013;${currentYear}
+      ${project.inceptionYear}$esc.unicode( '\u2013' )${currentYear}
 #*  *##else
       ${currentYear}
 #*  *##end
 ##
 #*  *##if ( ${project.organization} )
 #*    *##if ( ${project.organization.name} && ${project.organization.url} )
-#*      *#<a href="$project.organization.url">${project.organization.name}</a>
+#*      *#<a href="$project.organization.url">$esc.xml( 
${project.organization.name} )</a>
 #*    *##elseif ( ${project.organization.name} )
-#*      *#${project.organization.name}
+#*      *#$esc.xml( ${project.organization.name} )
 #*    *##end
 #*  *##end
 #**##end
@@ -522,9 +523,9 @@ $indent     </ul>##
 #*  *##end
 ##
 #*  *##if( $item.alt )
-#*    *##set ( $alt = ' alt="' + $item.alt + '"' )
+#*    *##set ( $alt = ' alt="' + $esc.xml( $item.alt ) + '"' )
 #*  *##else
-#*    *##set ( $alt = ' alt="' + $name + '"' )
+#*    *##set ( $alt = ' alt="' + $esc.xml( $name ) + '"' )
 #*  *##end
 ##
 #*  *##if( $item.border )
@@ -544,7 +545,7 @@ $indent     </ul>##
 #*    *##set ( $height = "" )
 #*  *##end
 ##
-#*  *#<a href="$href" title="$name" class="builtBy">##
+#*  *#<a href="$href" title="$esc.xml( $name )" class="builtBy">##
 #*    *#<img class="builtBy" $alt src="$img" style="$border$width$height" />##
 #*  *#</a>
 #**##end
@@ -796,9 +797,9 @@ Apache Maven Doxia Site Renderer#if( 
$doxiaSiteRendererVersion ) $doxiaSiteRende
 ##
 #macro( anchorJS )
 <script>
-       if(anchors) {
-         anchors.add();
-       }
+  if(anchors) {
+    anchors.add();
+  }
 </script>
 #end
 ##
diff --git a/src/main/resources/META-INF/maven/site.vm 
b/src/main/resources/META-INF/maven/site.vm
index 9d49dbd..6914df0 100644
--- a/src/main/resources/META-INF/maven/site.vm
+++ b/src/main/resources/META-INF/maven/site.vm
@@ -36,13 +36,13 @@
 ## put meta together
     <meta name="generator" content="#generatedBy()" />
 #foreach( $author in $authors )
-    <meta name="author" content="$author" />
+    <meta name="author" content="$esc.xml( $author )" />
 #end
 #if ( $documentDate )
     <meta name="date" content="$documentDate" />
 #end
 #if ( $title )
-    <title>$title</title>
+    <title>$esc.xml( $title )</title>
 #end
     <link rel="stylesheet" 
href="$relativePath/css/[email protected][email protected]" />
     <link rel="stylesheet" href="$relativePath/css/site.css" />
@@ -113,7 +113,7 @@
 #*            *##set ( $hrf = './' )
 #*          *##end
 #*        *##end
-#*        *#<a class="brand" href="$hrf" #if( $topBarIcon.getChild( 'alt' ) ) 
title="$topBarIcon.getChild( 'alt' ).getValue()"#end>##
+#*        *#<a class="brand" href="$hrf" #if( $topBarIcon.getChild( 'alt' ) ) 
title="$esc.xml( $topBarIcon.getChild( 'alt' ).getValue() )"#end>##
 ##
 #*        *##set ( $topBarIconName = $decoration.getCustomValue( 
'fluidoSkin.topBarIcon.name', $project.name ) )
 ##
@@ -124,9 +124,9 @@
 #*            *##set ( $src = $src.replaceAll( '\\', '/' ) )
 #*          *##end
 #*          *##set ( $alt = $decoration.getCustomValue( 
'fluidoSkin.topBarIcon.alt', $topBarIconName ) )
-#*          *#<img src="$src" alt="$alt" />
+#*          *#<img src="$src" alt="$esc.xml( $alt )" />
 #*        *##else
-#*          *#$topBarIconName
+#*          *#$esc.xml( $topBarIconName )
 #*        *##end
 ##
 #*        *#</a>
@@ -273,7 +273,7 @@
 #*      *##if ( $decoration.getCustomChild( 'fluidoSkin.copyrightClass' ) )
 #*        *##set ( $copyrightClass = ' class="' + $decoration.getCustomValue( 
'fluidoSkin.copyrightClass' ) + '"' )
 #*      *##end
-            <p$!copyrightClass>&#169;#copyright()#publishDate( "bottom" 
$decoration.publishDate $decoration.version )</p>
+            <p$!copyrightClass>$esc.unicode( '\u00A9' 
)#copyright()#publishDate( "bottom" $decoration.publishDate $decoration.version 
)</p>
 #*    *##end
         </div>
 ##

Reply via email to