You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Jeanne Waldman (JIRA)" <de...@myfaces.apache.org> on 2010/12/08 01:52:01 UTC
[jira] Created: (TRINIDAD-1972)
SkinStyleSheetParserUtils.trimQuotes trims mis-matched quotes
SkinStyleSheetParserUtils.trimQuotes trims mis-matched quotes
-------------------------------------------------------------
Key: TRINIDAD-1972
URL: https://issues.apache.org/jira/browse/TRINIDAD-1972
Project: MyFaces Trinidad
Issue Type: Bug
Components: Skinning
Reporter: Jeanne Waldman
Priority: Minor
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;
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (TRINIDAD-1972)
SkinStyleSheetParserUtils.trimQuotes trims mis-matched quotes
Posted by "Jeanne Waldman (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/TRINIDAD-1972?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jeanne Waldman resolved TRINIDAD-1972.
--------------------------------------
Resolution: Fixed
Fix Version/s: 2.0.0.4-core
> SkinStyleSheetParserUtils.trimQuotes trims mis-matched quotes
> -------------------------------------------------------------
>
> Key: TRINIDAD-1972
> URL: https://issues.apache.org/jira/browse/TRINIDAD-1972
> Project: MyFaces Trinidad
> Issue Type: Bug
> Components: Skinning
> Reporter: Jeanne Waldman
> Priority: Minor
> Fix For: 2.0.0.4-core
>
>
> 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;
> }
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.