Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Merkli2014-10-24 14:05:02 +0000
committerChristoph Schwank2014-10-24 14:35:00 +0000
commit95658f77b3bd6647958024194830ba45fbac520f (patch)
tree7d8b53e50ed103f5ad979abd01348c9812728192
parentea8a58a478e7ee6488ec9ea3da564a5f3fd043fc (diff)
downloadorg.eclipse.scout.rt-95658f77b3bd6647958024194830ba45fbac520f.tar.gz
org.eclipse.scout.rt-95658f77b3bd6647958024194830ba45fbac520f.tar.xz
org.eclipse.scout.rt-95658f77b3bd6647958024194830ba45fbac520f.zip
448638: HtmlUtility.cleanupCss throws
java.util.ConcurrentModificationException Change-Id: I4623957fa711a20bd2d913f43eaf5da6f77c6a52 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=448638 Reviewed-on: https://git.eclipse.org/r/35474 Tested-by: Hudson CI Reviewed-by: Christoph Schwank <christoph.schwank@bsiag.com>
-rw-r--r--org.eclipse.scout.commons/src/org/eclipse/scout/commons/HTMLUtility.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/org.eclipse.scout.commons/src/org/eclipse/scout/commons/HTMLUtility.java b/org.eclipse.scout.commons/src/org/eclipse/scout/commons/HTMLUtility.java
index c398e208df..fb9e4f2b71 100644
--- a/org.eclipse.scout.commons/src/org/eclipse/scout/commons/HTMLUtility.java
+++ b/org.eclipse.scout.commons/src/org/eclipse/scout/commons/HTMLUtility.java
@@ -18,9 +18,12 @@ import java.io.StringReader;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -379,6 +382,7 @@ public final class HTMLUtility {
}
}
// clean font tags if any styles are present
+ final Map<MutableAttributeSet, List<Object>> attributesToRemove = new HashMap<MutableAttributeSet, List<Object>>();
doc.writeLockEx();
visitDocument(doc, new IDocumentVisitor() {
@Override
@@ -390,11 +394,25 @@ public final class HTMLUtility {
public void visitAttribute(Element elem, AttributeSet atts, Object nm, Object value) {
if (nm == HTML.Attribute.FACE || nm == HTML.Attribute.SIZE || nm == CSS.Attribute.FONT_FAMILY || nm == CSS.Attribute.FONT_SIZE) {
if (atts instanceof MutableAttributeSet) {
- ((MutableAttributeSet) atts).removeAttribute(nm);
+ MutableAttributeSet mutableAttributeSet = (MutableAttributeSet) atts;
+ List<Object> attributes = attributesToRemove.get(mutableAttributeSet);
+ if (attributes == null) {
+ attributes = new ArrayList<Object>();
+ attributesToRemove.put(mutableAttributeSet, attributes);
+ }
+ attributes.add(nm);
}
}
}
});
+
+ for (Entry<MutableAttributeSet, List<Object>> entry : attributesToRemove.entrySet()) {
+ MutableAttributeSet mutableAttributeSet = entry.getKey();
+ for (Object nm : entry.getValue()) {
+ mutableAttributeSet.removeAttribute(nm);
+ }
+ }
+
doc.writeUnlockEx();
return htmlDoc;
}

Back to the top