On Jan 28, 2009, at 11:52 AM, tmortagne (SVN) wrote:
Author: tmortagne
Date: 2009-01-28 11:52:19 +0100 (Wed, 28 Jan 2009)
New Revision: 15814
Added:
platform/core/branches/xwiki-core-1.7/xwiki-rendering/src/test/
resources/escape/escape14.test
Modified:
platform/core/branches/xwiki-core-1.7/xwiki-rendering/src/main/
java/org/xwiki/rendering/renderer/XWikiSyntaxRenderer.java
platform/core/branches/xwiki-core-1.7/xwiki-rendering/src/test/
java/org/xwiki/rendering/RenderingTests.java
Log:
XWIKI-3170: Custom parameter ending syntax characters are not
escaped inside xwiki/2.0 custom parameter values
XWIKI-3143: Quotes are not escaped inside xwiki/2.0 custom parameter
values
Modified: platform/core/branches/xwiki-core-1.7/xwiki-rendering/src/
main/java/org/xwiki/rendering/renderer/XWikiSyntaxRenderer.java
===================================================================
--- platform/core/branches/xwiki-core-1.7/xwiki-rendering/src/main/
java/org/xwiki/rendering/renderer/XWikiSyntaxRenderer.java
2009-01-28 10:51:35 UTC (rev 15813)
+++ platform/core/branches/xwiki-core-1.7/xwiki-rendering/src/main/
java/org/xwiki/rendering/renderer/XWikiSyntaxRenderer.java
2009-01-28 10:52:19 UTC (rev 15814)
@@ -934,8 +934,8 @@
if (!parameters.isEmpty()) {
StringBuffer buffer = new StringBuffer("(%");
for (Map.Entry<String, String> entry :
parameters.entrySet()) {
- buffer.append('
').append
(entry.getKey()).append('=').append('\"').append(entry.getValue())
- .append('\"');
+ buffer.append('
').append(entry.getKey()).append('=').append('\"').append(
+ entry.getValue().replaceAll("[\\\\\"]", "\\\\
$0").replaceAll("\\%\\)", "~%)")).append('\"');
I think this requires a bit of comments to explain why this magic is
done :)
[snip]
Added:
platform/core/branches/xwiki-core-1.7/xwiki-rendering/src/
test/resources/escape/escape14.test
===================================================================
--- platform/core/branches/xwiki-core-1.7/xwiki-rendering/src/test/
resources/escape/escape14.test (rev 0)
+++ platform/core/branches/xwiki-core-1.7/xwiki-rendering/src/test/
resources/escape/escape14.test 2009-01-28 10:52:19 UTC (rev 15814)
@@ -0,0 +1,26 @@
+
.#---------------------------------------------------------------------------------------------------------
+.input|xwiki/2.0
I think a comment here would be good to explain what this test is
about since it's not that obvious.
+
.#---------------------------------------------------------------------------------------------------------
+(% style="font-(%weight: bold; ~%)font-family: \"monospace\"; font-
size: 14pt;" %)
+foobar
+.#-----------------------------------------------------
+.expect|event
+.#-----------------------------------------------------
+beginDocument
+beginParagraph [[style]=[font-(%weight: bold; %)font-family:
"monospace"; font-size: 14pt;]]
+onWord [foobar]
+endParagraph [[style]=[font-(%weight: bold; %)font-family:
"monospace"; font-size: 14pt;]]
+endDocument
+.#-----------------------------------------------------
+.expect|xhtml
+.#-----------------------------------------------------
+<p style="font-(%weight: bold; %)font-family:
"monospace"; font-size: 14pt;">foobar</p>
+.#-----------------------------------------------------
+.expect|xwiki
+.#-----------------------------------------------------
+(% style="font-(%weight: bold; ~%)font-family: \"monospace\"; font-
size: 14pt;" %)
+foobar
+.#-----------------------------------------------------
+.input|xhtml/1.0
+.#-----------------------------------------------------
+<p style="font-(%weight: bold; %)font-family:
"monospace"; font-size: 14pt;">foobar</p>
\ No newline at end of file
Thanks
-Vincent
http://xwiki.com
http://xwiki.org
http://massol.net