Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-646

StringEscapeUtils.unescapeJava doesn't handle octal escapes and Unicode with extra u

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: 3.0
    • Component/s: lang.*
    • Labels:
      None
    • Environment:

      Irrelevant

      Description

      CODE TO REPRODUCE BUG:

      System.out.println("\45");
      // %
      System.out.println(StringEscapeUtils.unescapeJava("\\45"));
      // 45, should be %
      
      System.out.println("\uu0030");
      // 0
      System.out.println(StringEscapeUtils.unescapeJava("\\uu0030"));
      // throws NestableRuntimeException:
      

      This is not compliant with the JLS, which allows both [OctalEscape] and extraneous u for [UnicodeMarker] in Java string literal.

      REFERENCES:

      3.10.6 Escape Sequences for Character and String Literals
      http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10.6

      3.3 Unicode Escapes
      http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.3

      EXTERNAL LINKS:

      http://stackoverflow.com/questions/3537706/howto-unescape-a-java-string-literal-in-java/

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              polygenelubricants polygenelubricants
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: