Uploaded image for project: 'MyFaces Trinidad'
  1. MyFaces Trinidad
  2. TRINIDAD-1972

SkinStyleSheetParserUtils.trimQuotes trims mis-matched quotes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 2.0.0-beta-1
    • Skinning
    • None

    Description

      SkinStyleSheetParserUtils.trimQuotes trims mis-matched quotes, though mismatched quotes should not be allowed. Here is the code.
      public static String trimQuotes(String in)

      { int length = in.length(); if (length <= 1) return in; // strip off the starting/ending quotes if there are any char firstChar = in.charAt(0); int firstCharIndex = 0; if ((firstChar == '\'') || (firstChar == '"')) firstCharIndex = 1; char lastChar = in.charAt(length-1); if ((lastChar == '\'') || (lastChar == '"')) length--; return in.substring(firstCharIndex, length); }

      We can change it to be more strict, but log a warning if they had mismatched quotes so they will know and they can fix them.
      public static String trimQuotesStrict(String in)
      {
      if ( in == null )
      return in;

      in = in.trim();
      boolean startsWithDoubleQuote = in.startsWith( "\"" );
      boolean startsWithSingleQuote = in.startsWith( "\'" );
      boolean endsWithDoubleQuote = in.endsWith( "\"" );
      boolean endsWithSingleQuote = in.endsWith( "\'" );

      if (( startsWithDoubleQuote && endsWithSingleQuote ) ||
      ( startsWithSingleQuote && endsWithDoubleQuote ))

      { if (_LOG.isWarning()) _LOG.warning("Skin parsing: fix mismatched quotes in " + in); }

      if ( startsWithDoubleQuote && endsWithDoubleQuote )
      return in.substring( 1, in.length() - 1 );
      if ( startsWithSingleQuote && endsWithSingleQuote )
      return in.substring( 1, in.length() - 1 );

      return in;
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            jeanne.waldman@oracle.com Jeanne Waldman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: