Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4114743

java.text.MessageFormat.applyPattern allows illegal patterns

XMLWordPrintable

    • 1.2beta4
    • sparc
    • solaris_2.5
    • Verified



      Name: dfC67450 Date: 02/24/98



      java.text.MessageFormat.applyPattern(String newPattern) does not throw any
      exceptions for illegal patterns.
      Javadoc says:

       * If a pattern is used, then unquoted braces in the pattern, if any, must match:
       * that is, "ab {0} de" and "ab '}' de" are ok, but "ab {0'}' de" and "ab } de" are
       * not.

      Here is the test demonstrating the bug:

      -----------------Test.java------------------------
      import java.text.*;

      public class Test {
          public static void main (String args[]){
              MessageFormat mf = new MessageFormat("initial pattern");
              String illegalPattern = "ab { '}' de";
              mf.applyPattern(illegalPattern);
              System.out.println("illegal pattern: \"" + illegalPattern + "\"");
              System.out.println("toPattern returns: \"" + mf.toPattern() + "\"");
          }
      }
      ---------Output from the test---------------------
      illegal pattern: "ab { '}' de"
      toPattern returns: "ab "
      --------------------------------------------------

      ======================================================================

            duke J. Duke
            dfazunensunw Dmitri Fazunenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: