Package com.google.caja.reporting

Examples of com.google.caja.reporting.MessageQueue


        Namespaces.HTML_NAMESPACE_URI, "media");
    extractStyles(linkEl, c, media);
  }

  private void extractStyles(Element el, EmbeddedContent c, Attr media) {
    MessageQueue mq = jobs.getMessageQueue();
    CssTree.StyleSheet stylesheet = null;
    try {
      stylesheet = (CssTree.StyleSheet) c.parse(
          jobs.getPluginMeta().getUriFetcher(), mq);
    } catch (ParseException ex) {
View Full Code Here


  private void moveOnLoadHandlerToEndOfBody(EmbeddedContent c) {
    Attr onload = (Attr) c.getSource();
    Element body = onload.getOwnerElement();
    body.removeAttributeNode(onload);

    MessageQueue mq = jobs.getMessageQueue();
    Block handler;
    try {
      handler = (Block) c.parse(jobs.getPluginMeta().getUriFetcher(), mq);
    } catch (ParseException ex) {
      ex.toMessageQueue(mq);
View Full Code Here

    // being cajoled at once since this can be mis-used for modularity
    // and we set up expectations on the part of our users to
    // maintain this behavior, regardless of whatever complexity that
    // might entail.

    MessageQueue mq = jobs.getMessageQueue();

    TemplateSanitizer ts = new TemplateSanitizer(htmlSchema, mq);
    for (IhtmlRoot ihtmlRoot : html) {
      ts.sanitize(ihtmlRoot.root);
    }
View Full Code Here

    if (cajoledData == null) {
      UriFetcher fetcher = makeFetcher(gadget);
      UriPolicy policy = makePolicy(gadget);
      URI javaGadgetUri = gadgetContext.getUrl().toJavaUri();
      MessageQueue mq = new SimpleMessageQueue();
      MessageContext context = new MessageContext();
      PluginMeta meta = new PluginMeta(fetcher, policy);
      PluginCompiler compiler = makePluginCompiler(meta, mq);

      compiler.setMessageContext(context);
View Full Code Here

    return sb.append('}').toString();
  }

  public static ParseTreeNode parse(String src) throws Exception {
    MessageContext mc = new MessageContext();
    MessageQueue mq = TestUtil.createTestMessageQueue(mc);
    InputSource is = new InputSource(new URI("file:///no/input/source"));
    CharProducer cp = CharProducer.Factory.create(new StringReader(src), is);
    JsLexer lexer = new JsLexer(cp);
    JsTokenQueue tq = new JsTokenQueue(lexer, is, JsTokenQueue.NO_COMMENT);
    Parser p = new Parser(tq, mq);
View Full Code Here

        throw new SAXException(e);
      }
    }

    private CajoledModule cajole(String text, String name) {
      MessageQueue mq = new EchoingMessageQueue(
          new PrintWriter(System.err), new MessageContext(), false);
      PluginMeta pm = new PluginMeta();
      pm.setPrecajoleMap(null);
      ModuleManager mgr = new ModuleManager(
          pm, BuildInfo.getInstance(),
          UriFetcher.NULL_NETWORK, mq);
      UncajoledModule input = uncajoled(text, name, mq);

      // TODO(felix8a): maybe should use compilation pipeline
      ArrayIndexOptimization.optimize(input);
      ParseTreeNode result = new ExpressionSanitizerCaja(mgr, null)
          .sanitize(input);

      if (mq.hasMessageAtLevel(MessageLevel.ERROR)) {
        throw new BuildException("Failed to cajole " + name);
      }
      if (!(result instanceof CajoledModule)) {
        throw new BuildException("No CajoledModule for " + name);
      }
View Full Code Here

        Namespaces.HTML_NAMESPACE_URI, "media");
    extractStyles(linkEl, c, media);
  }

  private void extractStyles(Element el, EmbeddedContent c, Attr media) {
    MessageQueue mq = jobs.getMessageQueue();
    CssTree.StyleSheet stylesheet = null;
    try {
      stylesheet = (CssTree.StyleSheet) c.parse(
          jobs.getPluginMeta().getUriFetcher(), mq);
    } catch (ParseException ex) {
View Full Code Here

  private void moveOnLoadHandlerToEndOfBody(EmbeddedContent c) {
    Attr onload = (Attr) c.getSource();
    Element body = onload.getOwnerElement();
    body.removeAttributeNode(onload);

    MessageQueue mq = jobs.getMessageQueue();
    Block handler;
    try {
      handler = (Block) c.parse(jobs.getPluginMeta().getUriFetcher(), mq);
    } catch (ParseException ex) {
      ex.toMessageQueue(mq);
View Full Code Here

      return null;
    }
  }

  public boolean apply(Jobs jobs) {
    MessageQueue mq = jobs.getMessageQueue();
    for (ListIterator<JobEnvelope> it = jobs.getJobs().listIterator();
         it.hasNext();) {
      JobEnvelope env = it.next();
      if (env.fromCache) { continue; }
      Job job = env.job;
      if (job.getType() != ContentType.HTML) { continue; }
      Dom dom = (Dom) job.getRoot();
      Node node = dom.getValue();
      URI baseUri = baseUri(node, job.getBaseUri(), dom.getFilePosition());
      if (baseUri != null) {
        try {
          baseUri = URI.create(UriUtil.normalizeUri(baseUri.toString()));
        } catch (URISyntaxException ex) {
          mq.addMessage(
              PluginMessageType.MALFORMED_URL, dom.getFilePosition(),
              MessagePart.Factory.valueOf(baseUri.toString()));
          baseUri = null;
        }
      }
View Full Code Here

   */
  /* visible for testing */ static boolean checkIdentifier(String candidate) {
    // Using a simple regex is possible if we reject anything but 7-bit ASCII.
    // However, this implementation ensures Caja has a single point of truth
    // regarding what constitutes a JS identifier.
    MessageQueue mq = new SimpleMessageQueue();
    Parser parser = new Parser(
        new JsTokenQueue(
            new JsLexer(
                CharProducer.Factory.fromString(
                    "var " + candidate + ";",
                    InputSource.UNKNOWN)),
            InputSource.UNKNOWN),
        mq);
    ParseTreeNode node;
    try { node = parser.parse(); } catch (ParseException e) { return false; }
    if (node == null || !mq.getMessages().isEmpty()) { return false; }
    Map<String, ParseTreeNode> bindings = Maps.newHashMap();
    if (!QuasiBuilder.match("{ var @p; }", node, bindings)) { return false; }
    if (bindings.size() != 1) { return false; }
    if (bindings.get("p") == null) { return false; }
    if (!(bindings.get("p") instanceof Identifier)) { return false; }
View Full Code Here

TOP

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

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.