You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Steve Hanmann (JIRA)" <ji...@apache.org> on 2008/04/02 17:43:31 UTC

[jira] Created: (LANG-421) StringEscapeUtils.escapeJava(String) escapes '/' characters

StringEscapeUtils.escapeJava(String) escapes '/' characters
-----------------------------------------------------------

                 Key: LANG-421
                 URL: https://issues.apache.org/jira/browse/LANG-421
             Project: Commons Lang
          Issue Type: Bug
    Affects Versions: 2.4
            Reporter: Steve Hanmann
            Priority: Blocker


Commons Lang 2.4 StringEscapeUtils.escapeJava(String) now escapes '/' characters, which is not a valid "escapable" character in Java strings.  I haven't tried the other Java escape/unescape methods to see if they have a similar problem, or that only Java "escapable" characters are escaped by escapeJava(String).

This bug may have appeared as an unintended side-effect of the fix for LANG-363.

Also the javadoc for escapeJava is now a little off, in that '/' should now be included in the sentence describing the differences between Java and Javascript strings, with respect to escaping rules.

The following is a JUnit3 test demonstrating the bug.

import junit.framework.TestCase;

import org.apache.commons.lang.StringEscapeUtils;

public class StringEscapeUtilsTest extends TestCase {
    public void testEscapeJavaWithSlash() {
        final String input = "String with a slash (/) in it";
        
        final String expected = input;
        final String actual   = StringEscapeUtils.escapeJava( input );

        /**
         * In 2.4 StringEscapeUtils.escapeJava(String) escapes '/' characters,
         * which are not a valid character to escape in a Java string.  
         */
        assertEquals( expected, actual );
    }
}



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-421) StringEscapeUtils.escapeJava(String) escapes '/' characters

Posted by "Steve Hanmann (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-421?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Hanmann updated LANG-421:
-------------------------------

    Attachment: StringEscapeUtilsTest.java

I attached the JUnit3 test as a file, after I noticed the inline test didn't retain end-of-lines.

> StringEscapeUtils.escapeJava(String) escapes '/' characters
> -----------------------------------------------------------
>
>                 Key: LANG-421
>                 URL: https://issues.apache.org/jira/browse/LANG-421
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 2.4
>            Reporter: Steve Hanmann
>            Priority: Blocker
>         Attachments: StringEscapeUtilsTest.java
>
>
> Commons Lang 2.4 StringEscapeUtils.escapeJava(String) now escapes '/' characters, which is not a valid "escapable" character in Java strings.  I haven't tried the other Java escape/unescape methods to see if they have a similar problem, or that only Java "escapable" characters are escaped by escapeJava(String).
> This bug may have appeared as an unintended side-effect of the fix for LANG-363.
> Also the javadoc for escapeJava is now a little off, in that '/' should now be included in the sentence describing the differences between Java and Javascript strings, with respect to escaping rules.
> The following is a JUnit3 test demonstrating the bug.
> import junit.framework.TestCase;
> import org.apache.commons.lang.StringEscapeUtils;
> public class StringEscapeUtilsTest extends TestCase {
>     public void testEscapeJavaWithSlash() {
>         final String input = "String with a slash (/) in it";
>         
>         final String expected = input;
>         final String actual   = StringEscapeUtils.escapeJava( input );
>         /**
>          * In 2.4 StringEscapeUtils.escapeJava(String) escapes '/' characters,
>          * which are not a valid character to escape in a Java string.  
>          */
>         assertEquals( expected, actual );
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-421) StringEscapeUtils.escapeJava(String) escapes '/' characters

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-421?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niall Pemberton updated LANG-421:
---------------------------------

    Fix Version/s:     (was: Nightly Builds)
                       (was: 3.0)
                   2.5

> StringEscapeUtils.escapeJava(String) escapes '/' characters
> -----------------------------------------------------------
>
>                 Key: LANG-421
>                 URL: https://issues.apache.org/jira/browse/LANG-421
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 2.4
>            Reporter: Steve Hanmann
>            Assignee: Gary Gregory
>            Priority: Blocker
>             Fix For: 2.5
>
>         Attachments: StringEscapeUtilsTest.java
>
>
> Commons Lang 2.4 StringEscapeUtils.escapeJava(String) now escapes '/' characters, which is not a valid "escapable" character in Java strings.  I haven't tried the other Java escape/unescape methods to see if they have a similar problem, or that only Java "escapable" characters are escaped by escapeJava(String).
> This bug may have appeared as an unintended side-effect of the fix for LANG-363.
> Also the javadoc for escapeJava is now a little off, in that '/' should now be included in the sentence describing the differences between Java and Javascript strings, with respect to escaping rules.
> The following is a JUnit3 test demonstrating the bug.
> import junit.framework.TestCase;
> import org.apache.commons.lang.StringEscapeUtils;
> public class StringEscapeUtilsTest extends TestCase {
>     public void testEscapeJavaWithSlash() {
>         final String input = "String with a slash (/) in it";
>         
>         final String expected = input;
>         final String actual   = StringEscapeUtils.escapeJava( input );
>         /**
>          * In 2.4 StringEscapeUtils.escapeJava(String) escapes '/' characters,
>          * which are not a valid character to escape in a Java string.  
>          */
>         assertEquals( expected, actual );
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-421) StringEscapeUtils.escapeJava(String) escapes '/' characters

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12584648#action_12584648 ] 

Gary Gregory commented on LANG-421:
-----------------------------------

The JLS reference is http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#101083

> StringEscapeUtils.escapeJava(String) escapes '/' characters
> -----------------------------------------------------------
>
>                 Key: LANG-421
>                 URL: https://issues.apache.org/jira/browse/LANG-421
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 2.4
>            Reporter: Steve Hanmann
>            Priority: Blocker
>         Attachments: StringEscapeUtilsTest.java
>
>
> Commons Lang 2.4 StringEscapeUtils.escapeJava(String) now escapes '/' characters, which is not a valid "escapable" character in Java strings.  I haven't tried the other Java escape/unescape methods to see if they have a similar problem, or that only Java "escapable" characters are escaped by escapeJava(String).
> This bug may have appeared as an unintended side-effect of the fix for LANG-363.
> Also the javadoc for escapeJava is now a little off, in that '/' should now be included in the sentence describing the differences between Java and Javascript strings, with respect to escaping rules.
> The following is a JUnit3 test demonstrating the bug.
> import junit.framework.TestCase;
> import org.apache.commons.lang.StringEscapeUtils;
> public class StringEscapeUtilsTest extends TestCase {
>     public void testEscapeJavaWithSlash() {
>         final String input = "String with a slash (/) in it";
>         
>         final String expected = input;
>         final String actual   = StringEscapeUtils.escapeJava( input );
>         /**
>          * In 2.4 StringEscapeUtils.escapeJava(String) escapes '/' characters,
>          * which are not a valid character to escape in a Java string.  
>          */
>         assertEquals( expected, actual );
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (LANG-421) StringEscapeUtils.escapeJava(String) escapes '/' characters

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-421?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory resolved LANG-421.
-------------------------------

       Resolution: Fixed
    Fix Version/s: Nightly Builds
                   3.0

Fixed. Added unit test method based on attachment provided.

> StringEscapeUtils.escapeJava(String) escapes '/' characters
> -----------------------------------------------------------
>
>                 Key: LANG-421
>                 URL: https://issues.apache.org/jira/browse/LANG-421
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 2.4
>            Reporter: Steve Hanmann
>            Assignee: Gary Gregory
>            Priority: Blocker
>             Fix For: 3.0, Nightly Builds
>
>         Attachments: StringEscapeUtilsTest.java
>
>
> Commons Lang 2.4 StringEscapeUtils.escapeJava(String) now escapes '/' characters, which is not a valid "escapable" character in Java strings.  I haven't tried the other Java escape/unescape methods to see if they have a similar problem, or that only Java "escapable" characters are escaped by escapeJava(String).
> This bug may have appeared as an unintended side-effect of the fix for LANG-363.
> Also the javadoc for escapeJava is now a little off, in that '/' should now be included in the sentence describing the differences between Java and Javascript strings, with respect to escaping rules.
> The following is a JUnit3 test demonstrating the bug.
> import junit.framework.TestCase;
> import org.apache.commons.lang.StringEscapeUtils;
> public class StringEscapeUtilsTest extends TestCase {
>     public void testEscapeJavaWithSlash() {
>         final String input = "String with a slash (/) in it";
>         
>         final String expected = input;
>         final String actual   = StringEscapeUtils.escapeJava( input );
>         /**
>          * In 2.4 StringEscapeUtils.escapeJava(String) escapes '/' characters,
>          * which are not a valid character to escape in a Java string.  
>          */
>         assertEquals( expected, actual );
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (LANG-421) StringEscapeUtils.escapeJava(String) escapes '/' characters

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12584648#action_12584648 ] 

ggregory@seagullsw.com edited comment on LANG-421 at 4/2/08 8:51 AM:
-----------------------------------------------------------

The JLS reference is http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#101083 (3.10.5 String Literals)

      was (Author: ggregory@seagullsw.com):
    The JLS reference is http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#101083
  
> StringEscapeUtils.escapeJava(String) escapes '/' characters
> -----------------------------------------------------------
>
>                 Key: LANG-421
>                 URL: https://issues.apache.org/jira/browse/LANG-421
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 2.4
>            Reporter: Steve Hanmann
>            Priority: Blocker
>         Attachments: StringEscapeUtilsTest.java
>
>
> Commons Lang 2.4 StringEscapeUtils.escapeJava(String) now escapes '/' characters, which is not a valid "escapable" character in Java strings.  I haven't tried the other Java escape/unescape methods to see if they have a similar problem, or that only Java "escapable" characters are escaped by escapeJava(String).
> This bug may have appeared as an unintended side-effect of the fix for LANG-363.
> Also the javadoc for escapeJava is now a little off, in that '/' should now be included in the sentence describing the differences between Java and Javascript strings, with respect to escaping rules.
> The following is a JUnit3 test demonstrating the bug.
> import junit.framework.TestCase;
> import org.apache.commons.lang.StringEscapeUtils;
> public class StringEscapeUtilsTest extends TestCase {
>     public void testEscapeJavaWithSlash() {
>         final String input = "String with a slash (/) in it";
>         
>         final String expected = input;
>         final String actual   = StringEscapeUtils.escapeJava( input );
>         /**
>          * In 2.4 StringEscapeUtils.escapeJava(String) escapes '/' characters,
>          * which are not a valid character to escape in a Java string.  
>          */
>         assertEquals( expected, actual );
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.