Package com.google.caja.parser.html

Examples of com.google.caja.parser.html.AttribKey


              key);
          out.add(fromBadContent(el));
        }
      }
      for (Attr a : Nodes.attributesOf(el)) {
        AttribKey aKey = AttribKey.forAttribute(key, a);
        HTML.Attribute aInfo = schema.lookupAttribute(aKey);
        if (aInfo != null) {
          switch (aInfo.getType()) {
            case URI:
              boolean isCode = false;
View Full Code Here


  }

  private boolean sanitizeAttr(
      ElKey elKey, Element el, Attr attrib, boolean ignore) {
    boolean valid = true;
    AttribKey attrKey = AttribKey.forAttribute(elKey, attrib);
    HTML.Attribute a = schema.lookupAttribute(attrKey);
    if (null == a) {
      if (!Placeholder.ID_ATTR.is(attrib)) {
        if (attrKey.localName.endsWith("__")) { valid = false; }
        else if (!attrKey.localName.startsWith(cajaPrefix)) {
View Full Code Here

  private void resolveRelativeUrls(Node n, URI base, MessageQueue mq) {
    if (n instanceof Element) {
      Element el = (Element) n;
      ElKey elKey = ElKey.forElement(el);
      for (Attr a : Nodes.attributesOf(el)) {
        AttribKey aKey = AttribKey.forAttribute(elKey, a);
        // If we ignored a relative base href, don't make it valid based on a
        // later one.
        if (BASE_HREF.equals(aKey)) { continue; }
        HTML.Attribute attrInfo = schema.lookupAttribute(aKey);
        if (attrInfo != null && attrInfo.getType() == HTML.Attribute.Type.URI) {
View Full Code Here

  /**
   * Attribute must exist in HTML 4 whitelist.
   */
  private boolean validateAttrib(ElKey elId, CssTree.Attrib attr) {
    AttribKey attrId = AttribKey.forAttribute(
        Namespaces.HTML_DEFAULT, elId, attr.getIdent());
    HTML.Attribute htmlAttribute = htmlSchema.lookupAttribute(attrId);
    if (null != htmlAttribute) {
      return validateAttribToSchema(elId, htmlAttribute, attr);
    } else {
View Full Code Here

    Nodes.setFilePositionFor(safe, pos);

    Attr id = null;
    for (Attr a : Nodes.attributesOf(el)) {
      if (!scriptsPerNode.containsKey(a)) { continue; }
      AttribKey attrKey = AttribKey.forAttribute(elKey, a);
      // Keep track of whether there is an ID so that we know whether or
      // not to remove any auto-generated ID later.
      Expression dynamicValue = (Expression) scriptsPerNode.get(a);
      if (ID.ns.uri != attrKey.ns.uri
          || !ID.localName.equals(attrKey.localName)) {
View Full Code Here

        continue;
      }
      HTML.Element elDetails = IHTML.SCHEMA.lookupElement(elKey);
      for (HTML.Attribute attrDetails : elDetails.getAttributes()) {
        if (attrDetails.isOptional()) { continue; }
        AttribKey attrKey = attrDetails.getKey();
        if (!ihtmlEl.hasAttributeNS(attrKey.ns.uri, attrKey.localName)) {
          mq.addMessage(
              IhtmlMessageType.MISSING_ATTRIB,
              Nodes.getFilePositionFor(ihtmlEl), elKey, attrKey);
          markBroken(ihtmlEl);
        }
      }
      for (Attr a : Nodes.attributesOf(ihtmlEl)) {
        AttribKey attrKey = AttribKey.forAttribute(elKey, a);
        if (IHTML.is(ihtmlEl, "call") && IHTML.is(attrKey.ns)
            && IHTML.isSafeIdentifier(a.getName())) {
          continue;
        }
        HTML.Attribute attrDetails = IHTML.SCHEMA.lookupAttribute(attrKey);
View Full Code Here

    HTML.Element elInfo = htmlSchema.lookupElement(elKey);
    List<HTML.Attribute> attrs = elInfo.getAttributes();
    if (attrs != null) {
      for (HTML.Attribute a : attrs) {
        AttribKey attrKey = a.getKey();
        if (!htmlSchema.isAttributeAllowed(attrKey)) { continue; }
        Attr attr = null;
        String aUri = attrKey.ns.uri;
        String aName = attrKey.localName;
        Attr unsafe = el.getAttributeNodeNS(aUri, aName);
View Full Code Here

    assertEquals(lookupAttribute("B", "ID"), withName(b, "ID"));
  }

  private HTML.Attribute lookupAttribute(
      String qualifiedEl, String qualifiedAttr) {
    AttribKey attr = AttribKey.forAttribute(
        Namespaces.HTML_DEFAULT, el(qualifiedEl), qualifiedAttr);
    return schema.lookupAttribute(attr);
  }
View Full Code Here

    return schema.lookupAttribute(attr);
  }

  private static HTML.Attribute withName(HTML.Element el, String qname) {
    List<HTML.Attribute> attrs = el.getAttributes();
    AttribKey key = AttribKey.forAttribute(
        Namespaces.HTML_DEFAULT, el.getKey(), qname);
    HTML.Attribute result = null;
    for (HTML.Attribute a : attrs) {
      if (key.localName.equals(a.getKey().localName)
          && key.ns.uri == a.getKey().ns.uri) {
View Full Code Here

              typePos, MessagePart.Factory.valueOf(mimeType), key);
          out.add(fromBadContent(el));
        }
      }
      for (Attr a : Nodes.attributesOf(el)) {
        AttribKey aKey = AttribKey.forAttribute(key, a);
        HTML.Attribute aInfo = schema.lookupAttribute(aKey);
        if (aInfo != null) {
          switch (aInfo.getType()) {
            case URI:
              boolean isCode = false;
View Full Code Here

TOP

Related Classes of com.google.caja.parser.html.AttribKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.