StartTag() { super(); attributes = new Attributes(); type = TokenType.StartTag; }
@Override Tag reset() { super.reset(); attributes = new Attributes(); // todo - would prefer these to be null, but need to check Element assertions return this; }
/** * Create a new, standalone element. * @param tag tag name */ public Element(String tag) { this(Tag.valueOf(tag), "", new Attributes()); }
@Override public Attributes attributes() { if (!hasAttributes()) attributes = new Attributes(); return attributes; }
Attributes getEnforcedAttributes(String tagName) { Attributes attrs = new Attributes(); TagName tag = TagName.valueOf(tagName); if (enforcedAttributes.containsKey(tag)) { Map<AttributeKey, AttributeValue> keyVals = enforcedAttributes.get(tag); for (Map.Entry<AttributeKey, AttributeValue> entry : keyVals.entrySet()) { attrs.put(entry.getKey().toString(), entry.getValue().toString()); } } return attrs; }
final void newAttribute() { if (attributes == null) attributes = new Attributes(); if (pendingAttributeName != null) { // the tokeniser has skipped whitespace control chars, but trimming could collapse to empty for other control codes, so verify here pendingAttributeName = pendingAttributeName.trim(); if (pendingAttributeName.length() > 0) { String value; if (hasPendingAttributeValue) value = pendingAttributeValue.length() > 0 ? pendingAttributeValue.toString() : pendingAttributeValueS; else if (hasEmptyAttributeValue) value = ""; else value = null; attributes.put(pendingAttributeName, value); } } pendingAttributeName = null; hasEmptyAttributeValue = false; hasPendingAttributeValue = false; reset(pendingAttributeValue); pendingAttributeValueS = null; }
private void ensureAttributes() { if (!hasAttributes()) { Object coreValue = value; Attributes attributes = new Attributes(); value = attributes; if (coreValue != null) attributes.put(nodeName(), (String) coreValue); } }
private ElementMeta createSafeElement(Element sourceEl) { String sourceTag = sourceEl.tagName(); Attributes destAttrs = new Attributes(); Element dest = new Element(Tag.valueOf(sourceTag), sourceEl.baseUri(), destAttrs); int numDiscarded = 0; Attributes sourceAttrs = sourceEl.attributes(); for (Attribute sourceAttr : sourceAttrs) { if (whitelist.isSafeAttribute(sourceTag, sourceEl, sourceAttr)) destAttrs.put(sourceAttr); else numDiscarded++; } Attributes enforcedAttrs = whitelist.getEnforcedAttributes(sourceTag); destAttrs.addAll(enforcedAttrs); return new ElementMeta(dest, numDiscarded); }
Attributes inputAttribs = new Attributes(); for (Attribute attr : startTag.attributes) { if (!StringUtil.inSorted(attr.getKey(), Constants.InBodyStartInputAttribs))
private static Element createSafeElement(Element sourceEl) { String sourceTag = sourceEl.tagName(); org.jsoup.nodes.Attributes destAttrs = new org.jsoup.nodes.Attributes(); Element dest = new Element(Tag.valueOf(sourceTag), sourceEl.baseUri(), destAttrs); org.jsoup.nodes.Attributes sourceAttrs = sourceEl.attributes(); for (Attribute sourceAttr : sourceAttrs) { destAttrs.put(sourceAttr); } return dest; }
Attributes attributes = new Attributes(); while (!tq.matchesAny("<", "/>", ">") && !tq.isEmpty()) { Attribute attribute = parseAttribute();
Attributes attributes = new Attributes(); while (!tq.matchesAny("<", "/>", ">") && !tq.isEmpty()) { Attribute attribute = parseAttribute();
Attributes attributes = new Attributes(); while (!tq.matchesAny("<", "/>", ">") && !tq.isEmpty()) { Attribute attribute = parseAttribute();
Attributes inputAttribs = new Attributes(); for (Attribute attr : startTag.attributes) { if (!StringUtil.in(attr.getKey(), Constants.InBodyStartInputAttribs))