Package com.google.caja.reporting

Examples of com.google.caja.reporting.Message


                      Nodes.getFilePositionFor(attr),
                      MessagePart.Factory.valueOf("'" + qname + "'"));
        el.removeAttributeNode(attr);
        return;
      }
      throw new ParseException(new Message(DomParserMessageType.IGNORING_TOKEN,
          Nodes.getFilePositionFor(attr),
          MessagePart.Factory.valueOf("'" + qname + "'")), e);
    }

    newAttr.setValue(attr.getValue());
View Full Code Here


                              .NOT_IGNORING_DOWNLEVEL_REVEALED_COMMENT,
                          t.pos, MessagePart.Factory.valueOf(t.text));
          }
          break;
        default:
          throw new ParseException(new Message(
              MessageType.MALFORMED_XHTML, t.pos,
              MessagePart.Factory.valueOf(t.text)));
      }
    }
  }
View Full Code Here

    Token<HtmlTokenType> last;
    tokloop:
    while (true) {
      if (tokens.isEmpty()) {
        throw new ParseException(
            new Message(DomParserMessageType.UNCLOSED_TAG, start));
      }
      last = tokens.peek();
      switch (last.type) {
      case TAGEND:
        tokens.advance();
        break tokloop;
      case ATTRNAME:
        AttrStub a = parseAttrib(out);
        if (a != null) { attrs.add(a); }
        break;
      default:
        throw new ParseException(new Message(
            MessageType.MALFORMED_XHTML, FilePosition.span(start, last.pos),
            MessagePart.Factory.valueOf(last.text)));
      }
    }
    return last;
View Full Code Here

            MessagePart.Factory.valueOf(name.text));
        return null;
      }
      // XML does not allow valueless attributes.
      throw new ParseException(
          new Message(MessageType.MISSING_ATTRIBUTE_VALUE,
                      value.pos, MessagePart.Factory.valueOf(value.text)));
    } else {
      value = Token.instance("", HtmlTokenType.ATTRVALUE, name.pos);
    }
    String rawValue = value.text;
View Full Code Here

          }
          escaped = !escaped && ch2 == '\\';
        }
        if (!closed) {
          throw new ParseException(
              new Message(
                  MessageType.UNTERMINATED_STRING_TOKEN,
                  p.filePositionForOffsets(start, end)));
        }
        type = JsTokenType.STRING;
        break;
      }
      case '/':
      {
        if (end == limit) {
          type = JsTokenType.PUNCTUATION;
        } else {
          char ch2 = buf[end];
          switch (ch2) {
          case '/':
            while (end < limit && !JsLexer.isJsLineSeparator(buf[end])) {
              ++end;
            }
            type = JsTokenType.COMMENT;
            break;
          case '*':
            {
              boolean star = false;
              boolean closed = false;
              while (++end < limit) {
                ch2 = buf[end];
                if (star && '/' == ch2) {
                  closed = true;
                  ++end;
                  break;
                } else {
                  star = (ch2 == '*');
                }
              }
              if (!closed) {
                throw new ParseException(
                    new Message(MessageType.UNTERMINATED_STRING_TOKEN,
                        p.filePositionForOffsets(start, p.getOffset())));
              }
              type = JsTokenType.COMMENT;
            }
            break;
          default:
            {
              if (lastNonCommentToken == null
                  || JsLexer.isRegexp(lastNonCommentToken.text)) {
                boolean closed = false;
                boolean escaped = false;
                boolean inCharSet = false;

                regex_body:
                do {
                  ch2 = buf[end];
                  if (JsLexer.isJsLineSeparator(ch2)) {
                    // will register as unterminated token below
                    break;
                  } else if (!escaped) {
                    switch (ch2) {
                      case '/':
                        if (!inCharSet) {
                          closed = true;
                          ++end;
                          break regex_body;
                        }
                        break;
                      case '[':
                        inCharSet = true;
                        break;
                      case ']':
                        inCharSet = false;
                        break;
                      case '\\':
                        escaped = true;
                        break;
                    }
                  } else {
                    escaped = false;
                  }
                  ++end;
                } while (end < limit);
                if (!closed) {
                  throw new ParseException(
                      new Message(MessageType.UNTERMINATED_STRING_TOKEN,
                          p.filePositionForOffsets(start, end)));
                }
                // Pick up any modifiers at the end, e.g. /foo/g
                // Firefox fails on "/foo/instanceof RegExp" with an
                // invalid identifiers error, so just pick up all letters
View Full Code Here

        } else if (schema.isElementVirtualized(elKey)) {
          valid &= virtualizeElement(elKey, el);

        } else if (!schema.isElementAllowed(elKey)) {
          // An explicitly disallowed but not virtualized element is an error.
          mq.getMessages().add(new Message(IhtmlMessageType.UNSAFE_UNVIRT_TAG,
              Nodes.getFilePositionFor(el), elKey));

          return false;
        }
        valid &= sanitizeAttrs(elKey, el, false);
View Full Code Here

  private boolean removeElement(Element el) {
    ElKey elKey = ElKey.forElement(el);
    Node p = el.getParentNode();
    if (p != null) {
      mq.getMessages().add(new Message(IhtmlMessageType.IGNORED_TAG,
          Nodes.getFilePositionFor(el), elKey));
      p.removeChild(el);
      return true;
    } else {
      mq.getMessages().add(new Message(IhtmlMessageType.UNSAFE_ROOT_TAG,
          Nodes.getFilePositionFor(el), elKey));
      return false;
    }
  }
View Full Code Here

  void match(CssTree.Term term, CssPropertyPartType type, Name propertyName) {
    this.match = new Match(term, type, propertyName, this.match);
  }

  void warn(MessageTypeInt msgType, MessagePart... parts) {
    warning = new MessageSList(new Message(msgType, parts), this.warning);
  }
View Full Code Here

            }
          } else if (node instanceof CssTree.Term
                     && (CssPropertyPartType.URI == propertyPartType(node))) {

            boolean remove = false;
            Message removeMsg = null;

            CssTree term = (CssTree.Term) node;
            CssTree.CssLiteral content =
                (CssTree.CssLiteral) term.children().get(0);

            if (content instanceof CssTree.Substitution) {
              return true// Handled by later pass.
            }

            String uriStr = content.getValue();
            try {
              URI baseUri = content.getFilePosition().source().getUri();
              URI relUri = new URI(uriStr);
              URI uri = baseUri.resolve(relUri);
              ExternalReference ref = new ExternalReference(
                  uri, baseUri, relUri, content.getFilePosition());
              Name propertyPart = propertyPart(node)// TODO
              if (uriPolicy != null) {
                String rewritten = UriPolicyNanny.apply(
                    uriPolicy,
                    ref, UriEffect.SAME_DOCUMENT, LoaderType.SANDBOXED,
                    Collections.singletonMap(
                        UriPolicyHintKey.CSS_PROP.key, propertyPart));
                if (rewritten == null) {
                  removeMsg = new Message(
                      PluginMessageType.DISALLOWED_URI,
                      node.getFilePosition(),
                      MessagePart.Factory.valueOf(uriStr));
                  remove = true;
                }
              }
            } catch (URISyntaxException ex) {
              removeMsg = new Message(
                  PluginMessageType.DISALLOWED_URI,
                  node.getFilePosition(), MessagePart.Factory.valueOf(uriStr));
              remove = true;
            }
View Full Code Here

      if (!allowedInLinkClass && propName.getCanonicalForm().startsWith("_")) {
        allowedInLinkClass = propertyNames.contains(Name.css(
            propName.getCanonicalForm().substring(1)));
      }
      if (!allowedInLinkClass || mightContainUrl(pd.getExpr())) {
        mq.getMessages().add(new Message(
            PluginMessageType.DISALLOWED_CSS_PROPERTY_IN_SELECTOR,
            this.invalidNodeMessageLevel,
            p.getFilePosition(), p.getPropertyName(),
            sel.node.getFilePosition()));
        mut.removeChild(child);
View Full Code Here

TOP

Related Classes of com.google.caja.reporting.Message

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.