groovy
  1. groovy
  2. GROOVY-4601

Stub generator doesn't escape strings with mixed single and double quotes

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.5
    • Fix Version/s: 1.8-rc-2, 1.7.9, 1.9-beta-1
    • Component/s: Compiler
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Single and double quotes when mixed in Groovy strings within annotations are not translated correctly into Java strings in generated stubs. Internal quotes are not escaped.

      This issue is related to GROOVY-4470. I used the same source code to demonstrate it.

      StringAnno.groovy
      @interface StringAnno {
        String val()
      }
      
      StringAnnoUser.groovy
      @StringAnno(val = 'single quote string with "double quote string"')
      class StringAnnoUser {}
      
      StringAnnoUser.java (generated stub)
      import java.lang.*;
      import java.io.*;
      import java.net.*;
      import java.util.*;
      import groovy.lang.*;
      import groovy.util.*;
      
      @StringAnno(val="single quote string with "double quote string"") public class StringAnnoUser
        extends java.lang.Object  implements
          groovy.lang.GroovyObject {
      public StringAnnoUser
      () {}
      public  groovy.lang.MetaClass getMetaClass() { return (groovy.lang.MetaClass)null;}
      public  void setMetaClass(groovy.lang.MetaClass mc) { }
      public  java.lang.Object invokeMethod(java.lang.String method, java.lang.Object arguments) { return null;}
      public  java.lang.Object getProperty(java.lang.String property) { return null;}
      public  void setProperty(java.lang.String property, java.lang.Object value) { }
      }
      

        Issue Links

          Activity

          Hide
          Guillaume Laforge added a comment -

          Added a test for this case.

          Show
          Guillaume Laforge added a comment - Added a test for this case.

            People

            • Assignee:
              Guillaume Laforge
              Reporter:
              Marcin Gryszko
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: