Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X ac6d069a8 -> 7c78768f7


GROOVY-7761: Groovydoc incorrectly rejects dollar signs and mucks up some 
backslashes during @code tag replacement. (closes #268)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/7c78768f
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/7c78768f
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/7c78768f

Branch: refs/heads/GROOVY_2_4_X
Commit: 7c78768f7ec7267f94755661ccfe0889802fa7da
Parents: ac6d069
Author: paulk <pa...@asert.com.au>
Authored: Mon Feb 22 09:39:00 2016 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Mon Feb 22 10:53:42 2016 +1000

----------------------------------------------------------------------
 .../groovy/tools/groovydoc/SimpleGroovyClassDoc.java  |  2 +-
 .../tools/groovydoc/SimpleGroovyClassDocTests.groovy  | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/7c78768f/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
----------------------------------------------------------------------
diff --git 
a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
 
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
index 2ecc866..a55aae8 100644
--- 
a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
+++ 
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
@@ -916,7 +916,7 @@ public class SimpleGroovyClassDoc extends 
SimpleGroovyAbstractableElementDoc imp
             while (matcher.find()) {
                 String tagName = matcher.group(1);
                 String tagBody = matcher.group(2);
-                String encodedBody = encodeAngleBrackets(tagBody);
+                String encodedBody = 
Matcher.quoteReplacement(encodeAngleBrackets(tagBody));
                 String replacement = "{@" + tagName + " " + encodedBody + "}";
                 matcher.appendReplacement(sb, replacement);
             }

http://git-wip-us.apache.org/repos/asf/groovy/blob/7c78768f/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocTests.groovy
----------------------------------------------------------------------
diff --git 
a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocTests.groovy
 
b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocTests.groovy
index 3682d29..9685cb5 100644
--- 
a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocTests.groovy
+++ 
b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocTests.groovy
@@ -47,10 +47,22 @@ class SimpleGroovyClassDocTests extends GroovyTestCase {
     void testEncodeAngleBracketsInTagBody() {
         def text = 'text with <tag1> outside and {@code <tag2> inside} a @code 
tag'
         def regex = SimpleGroovyClassDoc.CODE_REGEX
+        def encodedText = 
SimpleGroovyClassDoc.encodeAngleBracketsInTagBody(text, regex)
+        assert encodedText == 'text with <tag1> outside and {@code 
&lt;tag2&gt; inside} a @code tag'
+    }
 
+    void testEncodeAngleBracketsInTagBodyWithDollar() {
+        def text = 'text with dollar {@code $foo.bar} and dollar with less 
than {@code $foo < $bar}'
+        def regex = SimpleGroovyClassDoc.CODE_REGEX
         def encodedText = 
SimpleGroovyClassDoc.encodeAngleBracketsInTagBody(text, regex)
+        assert encodedText == 'text with dollar {@code $foo.bar} and dollar 
with less than {@code $foo &lt; $bar}'
+    }
 
-        assert encodedText == 'text with <tag1> outside and {@code 
&lt;tag2&gt; inside} a @code tag'
+    void testEncodeAngleBracketsInTagBodyLeavesSpecialChars() {
+        def text = 'text with illegal group ref {@code $3 \\$}'
+        def regex = SimpleGroovyClassDoc.CODE_REGEX
+        def encodedText = 
SimpleGroovyClassDoc.encodeAngleBracketsInTagBody(text, regex)
+        assert encodedText == text
     }
 
     void testEncodeAngleBrackets() {

Reply via email to