You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2007/12/09 00:43:33 UTC
svn commit: r602579 -
/xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/sac/CSSClassCondition.java
Author: cam
Date: Sat Dec 8 15:43:32 2007
New Revision: 602579
URL: http://svn.apache.org/viewvc?rev=602579&view=rev
Log:
Fix bug in CSS class name matching.
Modified:
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/sac/CSSClassCondition.java
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/sac/CSSClassCondition.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/sac/CSSClassCondition.java?rev=602579&r1=602578&r2=602579&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/sac/CSSClassCondition.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/sac/CSSClassCondition.java Sat Dec 8 15:43:32 2007
@@ -55,16 +55,20 @@
return false; // Can't match an unstylable element.
String attr = ((CSSStylableElement)e).getCSSClass();
String val = getValue();
+ int attrLen = attr.length();
+ int valLen = val.length();
+
int i = attr.indexOf(val);
- if (i == -1) {
- return false;
+ while (i != -1) {
+ if (i == 0 || Character.isSpaceChar(attr.charAt(i - 1))) {
+ if (i + valLen == attrLen ||
+ Character.isSpaceChar(attr.charAt(i + valLen))) {
+ return true;
+ }
+ }
+ i = attr.indexOf(val, i + valLen);
}
- if (i != 0 && !Character.isSpaceChar(attr.charAt(i - 1))) {
- return false;
- }
- int j = i + val.length();
- return (j == attr.length() ||
- (j < attr.length() && Character.isSpaceChar(attr.charAt(j))));
+ return false;
}
/**