diff --git a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/CSSEngine.java b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/CSSEngine.java index 41568bcfe..3cf4688eb 100644 --- a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/CSSEngine.java +++ b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/CSSEngine.java @@ -1210,6 +1210,8 @@ private LexicalUnit replaceLexicalProxy(StyleMap sm, LexicalUnit lexval, CSSStyl LexicalUnit lu = lexval; do { if (lu.getLexicalUnitType() == LexicalType.VAR) { + sm.putCustomPtyRelative(propIdx, true); + LexicalUnit newlu; LexicalUnit param = lu.getParameters(); String propertyName = param.getStringValue(); // Property name @@ -1266,19 +1268,8 @@ private LexicalUnit replaceLexicalProxy(StyleMap sm, LexicalUnit lexval, CSSStyl } continue; } else if (lu.getLexicalUnitType() == LexicalType.ATTR) { - if (valueManagers[propIdx].allowsURL()) { - return null; - } boolean isLexval = lu == lexval; LexicalUnit newlu = replacementAttrUnit(sm, lu, elt, parent, counter, ptySet, propIdx); - try { - counter.replaceCounter += lu.countReplaceBy(newlu); - } catch (CSSBudgetException e) { - throw createAttrResourceLimitException(e); - } - if (counter.replaceCounter >= REPLACE_COUNT_LIMIT) { - throw createAttrResourceLimitException(); - } if (newlu == null) { // The current lexical unit can be removed @@ -1290,6 +1281,17 @@ private LexicalUnit replaceLexicalProxy(StyleMap sm, LexicalUnit lexval, CSSStyl continue; } + sm.putAttrTainted(propIdx, true); + + try { + counter.replaceCounter += lu.countReplaceBy(newlu); + } catch (CSSBudgetException e) { + throw createAttrResourceLimitException(e); + } + if (counter.replaceCounter >= REPLACE_COUNT_LIMIT) { + throw createAttrResourceLimitException(); + } + if (newlu.getLexicalUnitType() != LexicalType.EMPTY) { // We do not want to mess with a declared value, so clone it newlu = newlu.clone(); @@ -1611,7 +1613,7 @@ private LexicalUnit replacementAttrUnit(StyleMap sm, LexicalUnit attr, CSSStylab } // Return fallback - return lu == null ? null : replaceLexicalProxy(sm, lu, elt, parent, counter, ptySet, propIdx); + return lu == null ? null : replaceLexicalProxy(sm, lu.clone(), elt, parent, counter, ptySet, propIdx); } private static boolean unitMatchesAttrType(LexicalUnit lunit, String attrtype) { @@ -3070,13 +3072,15 @@ protected void inlineStyleAttributeUpdated(CSSStylableElement elt, StyleMap styl boolean lh = (lineHeightIndex == -1) ? false : updated[lineHeightIndex]; boolean cl = (colorIndex == -1) ? false : updated[colorIndex]; boolean isRoot = elt.getOwnerDocument().getDocumentElement() == elt; + boolean cp = styleDeclarationUpdateHandler.updatedCustomProperties; for (int i = getNumberOfProperties() - 1; i >= 0; --i) { if (updated[i]) { count++; } else if ((fs && style.isFontSizeRelative(i)) || (lh && style.isLineHeightRelative(i)) || (cl && style.isColorRelative(i)) || (fs && isRoot && style.isRootFontSizeRelative(i)) - || (lh && isRoot && style.isRootLineHeightRelative(i))) { + || (lh && isRoot && style.isRootLineHeightRelative(i)) + || (cp && style.isCustomPtyRelative(i))) { updated[i] = true; clearComputedValue(style, i); count++; @@ -3218,13 +3222,15 @@ protected void propagateChanges(Node node, int[] props, boolean recascade) { boolean lh = (lineHeightIndex == -1) ? false : updated[lineHeightIndex]; boolean cl = (colorIndex == -1) ? false : updated[colorIndex]; boolean isRootFs = fs && elt.getOwnerDocument().getDocumentElement() == elt; + boolean cp = styleDeclarationUpdateHandler.updatedCustomProperties; int count = 0; for (int i = getNumberOfProperties() - 1; i >= 0; --i) { if (updated[i]) { count++; } else if ((fs && style.isFontSizeRelative(i)) || (lh && style.isLineHeightRelative(i)) - || (cl && style.isColorRelative(i)) || (isRootFs && style.isRootFontSizeRelative(i))) { + || (cl && style.isColorRelative(i)) || (isRootFs && style.isRootFontSizeRelative(i)) + || (cp && style.isCustomPtyRelative(i))) { updated[i] = true; clearComputedValue(style, i); count++; @@ -3288,6 +3294,7 @@ protected class StyleDeclarationUpdateHandler extends DocumentAdapter implements public StyleMap styleMap; public boolean[] updatedProperties = new boolean[getNumberOfProperties()]; + public boolean updatedCustomProperties; /** * SAC: Implements @@ -3319,6 +3326,11 @@ public void property(String name, LexicalUnit value, boolean important) { } } + @Override + public void lexicalProperty(String name, LexicalUnit value, boolean important) { + updatedCustomProperties = true; + } + @Override public void pendingValue(String name, PendingValue v, boolean important) { int i = getPropertyIndex(name); diff --git a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/StyleMap.java b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/StyleMap.java index d8824ba98..f8c991c67 100644 --- a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/StyleMap.java +++ b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/StyleMap.java @@ -52,6 +52,8 @@ public class StyleMap { public static final int ROOT_LINE_HEIGHT_RELATIVE_MASK = 0x0800; public static final int ROOT_FONT_SIZE_RELATIVE_MASK = 0x1000; public static final int VIEWPORT_RELATIVE_MASK = 0x2000; + public static final int CUSTOM_PTY_RELATIVE_MASK = 0x4000; + public static final int ATTR_TAINTED_MASK = 0x8000; public static final int ORIGIN_MASK = 0xE0000000; // 3 last bits @@ -109,6 +111,8 @@ public void setFixedCascadedStyle(boolean b) { /** * Returns the value at the given index, null if unspecified. + * + * @param i the property index. */ public Value getValue(int i) { return values[i]; @@ -116,6 +120,8 @@ public Value getValue(int i) { /** * Returns the mask of the given property value. + * + * @param i the property index. */ public int getMask(int i) { return masks[i]; @@ -123,6 +129,8 @@ public int getMask(int i) { /** * Tells whether the given property value is important. + * + * @param i the property index. */ public boolean isImportant(int i) { return (masks[i] & IMPORTANT_MASK) != 0; @@ -130,6 +138,8 @@ public boolean isImportant(int i) { /** * Tells whether the given property value is computed. + * + * @param i the property index. */ public boolean isComputed(int i) { return (masks[i] & COMPUTED_MASK) != 0; @@ -137,6 +147,8 @@ public boolean isComputed(int i) { /** * Tells whether the given cascaded property value is null. + * + * @param i the property index. */ public boolean isNullCascaded(int i) { return (masks[i] & NULL_CASCADED_MASK) != 0; @@ -145,6 +157,8 @@ public boolean isNullCascaded(int i) { /** * Tells whether the given cascaded property value was inherited from it's * parent or set locally. + * + * @param i the property index. */ public boolean isInherited(int i) { return (masks[i] & INHERITED_MASK) != 0; @@ -152,6 +166,8 @@ public boolean isInherited(int i) { /** * Returns the origin value. + * + * @param i the property index. */ public int getOrigin(int i) { return (masks[i] & ORIGIN_MASK); @@ -159,6 +175,8 @@ public int getOrigin(int i) { /** * Tells whether the given property value is relative to 'color'. + * + * @param i the property index. */ public boolean isColorRelative(int i) { return (masks[i] & COLOR_RELATIVE_MASK) != 0; @@ -167,6 +185,8 @@ public boolean isColorRelative(int i) { /** * Tells whether the given property value is relative to the parent's property * value. + * + * @param i the property index. */ public boolean isParentRelative(int i) { return (masks[i] & PARENT_RELATIVE_MASK) != 0; @@ -174,6 +194,8 @@ public boolean isParentRelative(int i) { /** * Tells whether the given property value is relative to 'line-height'. + * + * @param i the property index. */ public boolean isLineHeightRelative(int i) { return (masks[i] & LINE_HEIGHT_RELATIVE_MASK) != 0; @@ -181,6 +203,8 @@ public boolean isLineHeightRelative(int i) { /** * Tells whether the given property value is relative to 'font-size'. + * + * @param i the property index. */ public boolean isFontSizeRelative(int i) { return (masks[i] & FONT_SIZE_RELATIVE_MASK) != 0; @@ -189,6 +213,8 @@ public boolean isFontSizeRelative(int i) { /** * Tells whether the given property value is relative to 'line-height' of the * {@code :root} element. + * + * @param i the property index. */ public boolean isRootLineHeightRelative(int i) { return (masks[i] & ROOT_LINE_HEIGHT_RELATIVE_MASK) != 0; @@ -197,6 +223,8 @@ public boolean isRootLineHeightRelative(int i) { /** * Tells whether the given property value is relative to 'font-size' of the * {@code :root} element. + * + * @param i the property index. */ public boolean isRootFontSizeRelative(int i) { return (masks[i] & ROOT_FONT_SIZE_RELATIVE_MASK) != 0; @@ -205,6 +233,8 @@ public boolean isRootFontSizeRelative(int i) { /** * Tells whether the given property value is relative to the width of the * containing block. + * + * @param i the property index. */ public boolean isBlockWidthRelative(int i) { return (masks[i] & BLOCK_WIDTH_RELATIVE_MASK) != 0; @@ -213,6 +243,8 @@ public boolean isBlockWidthRelative(int i) { /** * Tells whether the given property value is relative to the height of the * containing block. + * + * @param i the property index. */ public boolean isBlockHeightRelative(int i) { return (masks[i] & BLOCK_HEIGHT_RELATIVE_MASK) != 0; @@ -220,11 +252,31 @@ public boolean isBlockHeightRelative(int i) { /** * Tells whether the given property value is relative to the viewport. + * + * @param i the property index. */ public boolean isViewportRelative(int i) { return (masks[i] & VIEWPORT_RELATIVE_MASK) != 0; } + /** + * Tells whether the given property value is relative to a custom property. + * + * @param i the property index. + */ + public boolean isCustomPtyRelative(int i) { + return (masks[i] & CUSTOM_PTY_RELATIVE_MASK) != 0; + } + + /** + * Tells whether the given property value is attr()-tainted. + * + * @param i the property index. + */ + public boolean isAttrTainted(int i) { + return (masks[i] & ATTR_TAINTED_MASK) != 0; + } + /** * Puts a property value, given the property index. * @@ -247,6 +299,9 @@ public void putMask(int i, int m) { /** * Sets the priority of a property value. + * + * @param i the property index. + * @param b if {@code true} sets the flag, unsets otherwise. */ public void putImportant(int i, boolean b) { if (b) @@ -257,6 +312,9 @@ public void putImportant(int i, boolean b) { /** * Sets the origin of the given value. + * + * @param i the property index. + * @param val the origin. */ public void putOrigin(int i, int val) { masks[i] &= ~ORIGIN_MASK; @@ -265,6 +323,9 @@ public void putOrigin(int i, int val) { /** * Sets the computed flag of a property value. + * + * @param i the property index. + * @param b if {@code true} sets the flag, unsets otherwise. */ public void putComputed(int i, boolean b) { if (b) @@ -275,6 +336,9 @@ public void putComputed(int i, boolean b) { /** * Sets the null-cascaded flag of a property value. + * + * @param i the property index. + * @param b if {@code true} sets the flag, unsets otherwise. */ public void putNullCascaded(int i, boolean b) { if (b) @@ -286,6 +350,9 @@ public void putNullCascaded(int i, boolean b) { /** * Sets the inherited flag of a property value. If true this computed value was * inherited from it's parent. + * + * @param i the property index. + * @param b if {@code true} sets the flag, unsets otherwise. */ public void putInherited(int i, boolean b) { if (b) @@ -296,6 +363,9 @@ public void putInherited(int i, boolean b) { /** * Sets the color-relative flag of a property value. + * + * @param i the property index. + * @param b if {@code true} sets the flag, unsets otherwise. */ public void putColorRelative(int i, boolean b) { if (b) @@ -306,6 +376,9 @@ public void putColorRelative(int i, boolean b) { /** * Sets the parent-relative flag of a property value. + * + * @param i the property index. + * @param b if {@code true} sets the flag, unsets otherwise. */ public void putParentRelative(int i, boolean b) { if (b) @@ -316,6 +389,9 @@ public void putParentRelative(int i, boolean b) { /** * Sets the line-height-relative flag of a property value. + * + * @param i the property index. + * @param b if {@code true} sets the flag, unsets otherwise. */ public void putLineHeightRelative(int i, boolean b) { if (b) @@ -326,6 +402,9 @@ public void putLineHeightRelative(int i, boolean b) { /** * Sets the font-size-relative flag of a property value. + * + * @param i the property index. + * @param b if {@code true} sets the flag, unsets otherwise. */ public void putFontSizeRelative(int i, boolean b) { if (b) @@ -336,6 +415,9 @@ public void putFontSizeRelative(int i, boolean b) { /** * Sets the root-line-height-relative flag of a property value. + * + * @param i the property index. + * @param b if {@code true} sets the flag, unsets otherwise. */ public void putRootLineHeightRelative(int i, boolean b) { if (b) @@ -346,6 +428,9 @@ public void putRootLineHeightRelative(int i, boolean b) { /** * Sets the root-font-size-relative flag of a property value. + * + * @param i the property index. + * @param b if {@code true} sets the flag, unsets otherwise. */ public void putRootFontSizeRelative(int i, boolean b) { if (b) @@ -356,6 +441,9 @@ public void putRootFontSizeRelative(int i, boolean b) { /** * Sets the block-width-relative flag of a property value. + * + * @param i the property index. + * @param b if {@code true} sets the flag, unsets otherwise. */ public void putBlockWidthRelative(int i, boolean b) { if (b) @@ -366,6 +454,9 @@ public void putBlockWidthRelative(int i, boolean b) { /** * Sets the block-height-relative flag of a property value. + * + * @param i the property index. + * @param b if {@code true} sets the flag, unsets otherwise. */ public void putBlockHeightRelative(int i, boolean b) { if (b) @@ -376,6 +467,9 @@ public void putBlockHeightRelative(int i, boolean b) { /** * Sets the viewport-relative flag of a property value. + * + * @param i the property index. + * @param b if {@code true} sets the flag, unsets otherwise. */ public void putViewportRelative(int i, boolean b) { if (b) @@ -384,6 +478,32 @@ public void putViewportRelative(int i, boolean b) { masks[i] &= ~VIEWPORT_RELATIVE_MASK; } + /** + * Sets the custom-property-relative flag of a property value. + * + * @param i the property index. + * @param b if {@code true} sets the flag, unsets otherwise. + */ + public void putCustomPtyRelative(int i, boolean b) { + if (b) + masks[i] |= CUSTOM_PTY_RELATIVE_MASK; + else + masks[i] &= ~CUSTOM_PTY_RELATIVE_MASK; + } + + /** + * Marks or clears a property as attr()-tainted. + * + * @param i the property index. + * @param b if {@code true} marks the property as attr()-tainted. + */ + public void putAttrTainted(int i, boolean b) { + if (b) + masks[i] |= ATTR_TAINTED_MASK; + else + masks[i] &= ~ATTR_TAINTED_MASK; + } + /** * Set a custom property value. * diff --git a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/AbstractValueManager.java b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/AbstractValueManager.java index 41831a62e..cdd14300d 100644 --- a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/AbstractValueManager.java +++ b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/AbstractValueManager.java @@ -27,6 +27,7 @@ import io.sf.carte.doc.style.css.property.StyleValue; import io.sf.carte.doc.style.css.property.ValueFactory; import io.sf.carte.echosvg.css.engine.CSSEngine; +import io.sf.carte.echosvg.css.engine.CSSEngineUserAgent; import io.sf.carte.echosvg.css.engine.CSSStylableElement; import io.sf.carte.echosvg.css.engine.StyleMap; @@ -98,6 +99,14 @@ public Value computeValue(CSSStylableElement elt, String pseudo, CSSEngine engin Value value) { if (value.getPrimitiveType() == Type.URI) { + if (sm.isAttrTainted(idx)) { + CSSEngineUserAgent ua = engine.getCSSEngineUserAgent(); + if (ua != null) { + ua.displayMessage("attr()-tainted value: " + value.getCssText()); + } + return null; + } + // For performance, set the parsed value as the cssText now. String uri = value.getURIValue(); return new URIValue(uri, uri); diff --git a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/ValueManager.java b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/ValueManager.java index 4eb295fc7..6a421bd6b 100644 --- a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/ValueManager.java +++ b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/ValueManager.java @@ -59,19 +59,6 @@ public interface ValueManager { */ boolean isAdditiveProperty(); - /** - * Allows URL values. - *
- * If this property accepts URL values, then {@code attr()} values cannot be - * used. - *
- * - * @return {@code true} if URL values are allowed by this property. - */ - default boolean allowsURL() { - return false; - } - /** * Returns the type of value this manager handles. This should be one of the * TYPE_* constants defined in {@link io.sf.carte.echosvg.util.SVGTypes}. diff --git a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/css2/CursorManager.java b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/css2/CursorManager.java index 7a3698bce..d7846d7c0 100644 --- a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/css2/CursorManager.java +++ b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/css2/CursorManager.java @@ -25,6 +25,7 @@ import io.sf.carte.doc.style.css.CSSValue.Type; import io.sf.carte.doc.style.css.nsac.LexicalUnit; import io.sf.carte.echosvg.css.engine.CSSEngine; +import io.sf.carte.echosvg.css.engine.CSSEngineUserAgent; import io.sf.carte.echosvg.css.engine.CSSStylableElement; import io.sf.carte.echosvg.css.engine.StyleMap; import io.sf.carte.echosvg.css.engine.value.AbstractValueManager; @@ -97,11 +98,6 @@ public boolean isAdditiveProperty() { return false; } - @Override - public boolean allowsURL() { - return true; - } - /** * Implements {@link ValueManager#getPropertyType()}. */ @@ -202,8 +198,16 @@ public Value computeValue(CSSStylableElement elt, String pseudo, CSSEngine engin int len = value.getLength(); ListValue result = new ListValue(' '); for (int i = 0; i < len; i++) { - Value v = value.item(0); + Value v = value.item(i); if (v.getPrimitiveType() == Type.URI) { + if (sm.isAttrTainted(idx)) { + CSSEngineUserAgent ua = engine.getCSSEngineUserAgent(); + if (ua != null) { + ua.displayMessage("attr()-tainted value: " + value.getCssText()); + } + return null; + } + // For performance, use the absolute value as the cssText now. String uri = v.getURIValue(); result.append(new URIValue(uri, uri)); @@ -213,6 +217,7 @@ public Value computeValue(CSSStylableElement elt, String pseudo, CSSEngine engin } return result; } + return super.computeValue(elt, pseudo, engine, idx, sm, value); } diff --git a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/css2/SrcManager.java b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/css2/SrcManager.java index 1fb189139..dc60057e3 100644 --- a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/css2/SrcManager.java +++ b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/css2/SrcManager.java @@ -22,8 +22,13 @@ import org.w3c.dom.DOMException; +import io.sf.carte.doc.style.css.CSSValue; +import io.sf.carte.doc.style.css.CSSValue.Type; import io.sf.carte.doc.style.css.nsac.LexicalUnit; import io.sf.carte.echosvg.css.engine.CSSEngine; +import io.sf.carte.echosvg.css.engine.CSSEngineUserAgent; +import io.sf.carte.echosvg.css.engine.CSSStylableElement; +import io.sf.carte.echosvg.css.engine.StyleMap; import io.sf.carte.echosvg.css.engine.value.IdentifierManager; import io.sf.carte.echosvg.css.engine.value.ListValue; import io.sf.carte.echosvg.css.engine.value.RevertValue; @@ -85,11 +90,6 @@ public boolean isAdditiveProperty() { return false; } - @Override - public boolean allowsURL() { - return true; - } - /** * Implements {@link ValueManager#getPropertyType()}. */ @@ -225,6 +225,23 @@ public Value createValue(final LexicalUnit lunit, CSSEngine engine) throws DOMEx } } + @Override + public Value computeValue(CSSStylableElement elt, String pseudo, CSSEngine engine, int idx, StyleMap sm, + Value value) { + if (sm.isAttrTainted(idx) && value.getCssValueType() == CSSValue.CssType.LIST) { + for (Value v : (ListValue) value) { + if (v.getPrimitiveType() == Type.URI) { + CSSEngineUserAgent ua = engine.getCSSEngineUserAgent(); + if (ua != null) { + ua.displayMessage("attr()-tainted value: " + value.getCssText()); + } + return null; + } + } + } + return super.computeValue(elt, pseudo, engine, idx, sm, value); + } + /** * Implements {@link IdentifierManager#getIdentifiers()}. */ diff --git a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/ClipPathManager.java b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/ClipPathManager.java index e55913711..7b48381a8 100644 --- a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/ClipPathManager.java +++ b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/ClipPathManager.java @@ -76,11 +76,6 @@ public boolean isAdditiveProperty() { return false; } - @Override - public boolean allowsURL() { - return true; - } - /** * Implements {@link ValueManager#getPropertyType()}. */ diff --git a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/ColorProfileManager.java b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/ColorProfileManager.java index 741ee9706..3469998d6 100644 --- a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/ColorProfileManager.java +++ b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/ColorProfileManager.java @@ -79,11 +79,6 @@ public boolean isAdditiveProperty() { return false; } - @Override - public boolean allowsURL() { - return true; - } - /** * Implements {@link ValueManager#getPropertyType()}. */ diff --git a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/FilterManager.java b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/FilterManager.java index 3f0184b4a..559f135e3 100644 --- a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/FilterManager.java +++ b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/FilterManager.java @@ -76,11 +76,6 @@ public boolean isAdditiveProperty() { return false; } - @Override - public boolean allowsURL() { - return true; - } - /** * Implements {@link ValueManager#getPropertyType()}. */ diff --git a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/MarkerManager.java b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/MarkerManager.java index 8c6ca693b..b057b99ef 100644 --- a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/MarkerManager.java +++ b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/MarkerManager.java @@ -80,11 +80,6 @@ public boolean isAdditiveProperty() { return false; } - @Override - public boolean allowsURL() { - return true; - } - /** * Implements {@link ValueManager#getPropertyType()}. */ diff --git a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/MaskManager.java b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/MaskManager.java index 813a76a56..fbd5308c6 100644 --- a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/MaskManager.java +++ b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/MaskManager.java @@ -68,11 +68,6 @@ public boolean isAdditiveProperty() { return false; } - @Override - public boolean allowsURL() { - return true; - } - /** * Implements {@link ValueManager#getPropertyType()}. */ diff --git a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/SVGPaintManager.java b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/SVGPaintManager.java index 0f59bd6bd..32b740bc8 100644 --- a/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/SVGPaintManager.java +++ b/echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/value/svg/SVGPaintManager.java @@ -22,6 +22,7 @@ import io.sf.carte.doc.style.css.nsac.LexicalUnit; import io.sf.carte.echosvg.css.engine.CSSEngine; +import io.sf.carte.echosvg.css.engine.CSSEngineUserAgent; import io.sf.carte.echosvg.css.engine.CSSStylableElement; import io.sf.carte.echosvg.css.engine.StyleMap; import io.sf.carte.echosvg.css.engine.value.ListValue; @@ -84,11 +85,6 @@ public boolean isAdditiveProperty() { return true; } - @Override - public boolean allowsURL() { - return true; - } - /** * Implements {@link ValueManager#getPropertyType()}. */ @@ -152,8 +148,15 @@ public Value computeValue(CSSStylableElement elt, String pseudo, CSSEngine engin if (value.getCssValueType() == Value.CssType.LIST) { Value v = value.item(0); if (v.getPrimitiveType() == Value.Type.URI) { + if (sm.isAttrTainted(idx)) { + CSSEngineUserAgent ua = engine.getCSSEngineUserAgent(); + if (ua != null) { + ua.displayMessage("attr()-tainted value: " + value.getCssText()); + } + return null; + } v = value.item(1); - if (v.isIdentifier(CSSConstants.CSS_NONE_VALUE)) { + if (v == null || v.isIdentifier(CSSConstants.CSS_NONE_VALUE)) { return value; } Value t = super.computeValue(elt, pseudo, engine, idx, sm, v); diff --git a/samples/tests/spec2/styling/attrValues.svg b/samples/tests/spec2/styling/attrValues.svg index 2d7e30acd..8bb408221 100644 --- a/samples/tests/spec2/styling/attrValues.svg +++ b/samples/tests/spec2/styling/attrValues.svg @@ -40,37 +40,35 @@ circle, ellipse { } @media screen and (100px <= width <= 900px) { - circle { - stroke-width: attr(stroke-width length); - } - g { - fill: attr(data-color color); /* Has no effect, fill can't take attr() */ - stroke: attr(data-color color); /* Has no effect, stroke can't take attr() */ - stroke-width: attr(stroke-width length); + circle, ellipse { + fill: attr(data-color color, #9ad6c2); + stroke: attr(data-stroke color); + stroke-width: attr(data-stroke-width length); } } text.itemdesc { - font: bold attr(data-font-size length) "Open Sans", sans-serif; - fill: var(--textColor); + font: bold attr(data-font-size length,14pt) "Open Sans", sans-serif; + fill: attr(data-color color, var(--textColor)); } /*]]>*/