From 23ddae130a53fa38327505e0538156bcd3697187 Mon Sep 17 00:00:00 2001 From: kitfox Date: Fri, 24 Aug 2012 15:48:06 +0000 Subject: Fixing parsing empty content in style attribute. git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@122 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b --- src/main/java/com/kitfox/svg/xml/XMLParseUtil.java | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java b/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java index 0d0121b..85199f4 100644 --- a/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java +++ b/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java @@ -789,10 +789,6 @@ public class XMLParseUtil */ public static HashMap parseStyle(String styleString, HashMap map) { final Pattern patSemi = Pattern.compile(";"); - final Pattern patColonSpace = Pattern.compile(":"); - - //Strips left and right whitespace - final Matcher matcherContent = Pattern.compile("\\s*([^\\s](.*[^\\s])?)\\s*").matcher(""); String[] styles = patSemi.split(styleString); @@ -803,17 +799,16 @@ public class XMLParseUtil continue; } - String[] vals = patColonSpace.split(styles[i]); - - matcherContent.reset(vals[0]); - matcherContent.matches(); - vals[0] = matcherContent.group(1); + int colon = styles[i].indexOf(':'); + if (colon == -1) + { + continue; + } - matcherContent.reset(vals[1]); - matcherContent.matches(); - vals[1] = matcherContent.group(1); + String key = styles[i].substring(0, colon).trim(); + String value = styles[i].substring(colon + 1).trim(); - map.put(vals[0], new StyleAttribute(vals[0], vals[1])); + map.put(key, new StyleAttribute(key, value)); } return map; -- cgit v1.2.3-55-g7522