Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7900242

jtreg -xml generates invalid XML

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • jtreg4.1
    • jtreg4.1
    • tools
    • None

      I tried to use jtreg -xml:verify recently but I found that a number of
      jdk tests emit control characters in their output which results in
      illegal characters in the XML output.

      I worked around it with the attached patch (which just drops the control
      characters except for 0x9, 0xA and 0xD). I bring it out as it may be
      something to look into more as there are other restricted characters and
      maybe they should be mapped to something rather than dropped.

      -Alan


      diff --git a/src/share/classes/com/sun/javatest/regtest/XMLWriter.java
      b/src/share/classes/com/sun/javatest/regtest/XMLWriter.java
      --- a/src/share/classes/com/sun/javatest/regtest/XMLWriter.java
      +++ b/src/share/classes/com/sun/javatest/regtest/XMLWriter.java
      @@ -417,6 +417,7 @@
            private static final Pattern XML_AMP = Pattern.compile("&");
            private static final Pattern XML_QUOTE = Pattern.compile("\"");
            private static final Pattern XML_APOS = Pattern.compile("\'");
      + private static final Pattern XML_ILLEGAL =
      Pattern.compile("[\\p{Cntrl}&&[^\\u0009\\u000A\\u000D]]");

            // sanitize the string for xml presentation
            public void sanitize(String in) {
      @@ -429,6 +430,7 @@
                    in = XML_LT.matcher(in).replaceAll("<");
                    in = XML_QUOTE.matcher(in).replaceAll(""");
                    in = XML_APOS.matcher(in).replaceAll("'");
      + in = XML_ILLEGAL.matcher(in).replaceAll("");
                    ps.print(in);
                }
            }

            jjg Jonathan Gibbons
            amlu Amy Lu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: