Package com.google.caja.lexer

Examples of com.google.caja.lexer.ExternalReference


                URI relUri = new URI(uriStr);
                URI uri = baseUri.resolve(relUri);
                // Rewrite the URI.
                // TODO(mikesamuel): for content: and other URI types, use
                // mime-type of text/*.
                ExternalReference ref = new ExternalReference(
                    uri, baseUri, relUri, content.getFilePosition());
                CssTree.UriLiteral replacement;
                if (uriPolicy != null) {
                  String rewrittenUri = UriPolicyNanny.apply(
                      uriPolicy,
View Full Code Here


    if (inputFetchedData == null) {
      String content = CajaArguments.CONTENT.get(args);
      if (emptyOrNull(content)) {
        try {
          inputFetchedData = uriFetcher.fetch(
              new ExternalReference(inputUri, FilePosition.UNKNOWN),
              expectedInputContentType);
        } catch (UriFetcher.UriFetchException ex) {
          ex.toMessageQueue(mq);
          return null;
        }
View Full Code Here

    try {
      if (null == meta) {
        return null;
      }
      FetchedData data = meta.getUriFetcher().fetch(
          new ExternalReference(is.getUri(), FilePosition.UNKNOWN), "*/*");
      return data.getTextualContent();
    } catch (UriFetchException e) {
      e.printStackTrace();
      // Failed heuristic, return null
    } catch (UnsupportedEncodingException e) {
View Full Code Here

  private void findEmbeddedContent(Node node, List<EmbeddedContent> out) {
    if (node instanceof Element) {
      Element el = (Element) node;
      ElKey key = ElKey.forElement(el);
      ContentType expected = null;
      ExternalReference extRef = null;
      String defaultMimeType = null;
      EmbeddedContent.Scheduling scheduling = EmbeddedContent.Scheduling.NORMAL;
      if (SCRIPT.equals(key)) {
        expected = ContentType.JS;
        extRef = externalReferenceFromAttr(el, SCRIPT_SRC);
View Full Code Here

          boolean loaded;
          CharProducer cp = null;
          public CharProducer apply(UriFetcher fetcher) {
            if (!loaded) {
              URI uri = extRef.getUri();
              ExternalReference toLoad = extRef;
              if (!uri.isAbsolute() && baseUri != null) {
                toLoad = new ExternalReference(
                    baseUri.resolve(uri),
                    extRef.getReferencePosition());
              }
              try {
                cp = fetcher.fetch(toLoad, t.mimeType).getTextualContent();
              } catch (UriFetcher.UriFetchException ex) {
                cp = null// Handled below.
              } catch (UnsupportedEncodingException ex) {
                cp = null// Handled below.
              }
              mc.addInputSource(new InputSource(toLoad.getUri()));
              loaded = true;
            }
            if (cp == null) {
              URI srcUri = extRef.getUri();
              String errUri = srcUri.isAbsolute()
View Full Code Here

      mq.getMessages().add(
          new Message(PluginMessageType.MALFORMED_URL, MessageLevel.ERROR,
                      Nodes.getFilePositionFor(attr), a));
      return null;
    }
    return new ExternalReference(uri, Nodes.getFilePositionForValue(attr));
  }
View Full Code Here

    if (inputFetchedData == null) {
      String content = CajaArguments.CONTENT.get(args);
      if (emptyOrNull(content)) {
        try {
          inputFetchedData = uriFetcher.fetch(
              new ExternalReference(inputUri, FilePosition.UNKNOWN),
              expectedInputContentType);
        } catch (UriFetcher.UriFetchException ex) {
          ex.toMessageQueue(mq);
          return null;
        }
View Full Code Here

                IhtmlMessageType.MALFORMED_URI, pos,
                MessagePart.Factory.valueOf(value));
            return noResult(attr);
          }
          if (meta.getUriPolicy() != null) {
            ExternalReference ref = new ExternalReference(uri, pos);
            String rewrittenUri = UriPolicyNanny.apply(
                meta.getUriPolicy(),
                ref, attr.attrInfo.getUriEffect(),
                attr.attrInfo.getLoaderType(),
                Collections.singletonMap(
                    UriPolicyHintKey.XML_ATTR.key,
                    attr.attrInfo.getKey().toString()));
            if (rewrittenUri == null) {
              mq.addMessage(
                  PluginMessageType.DISALLOWED_URI, pos,
                  MessagePart.Factory.valueOf(uri.toString()));
              return noResult(attr);
            }
            dynamicValue = StringLiteral.valueOf(
                ref.getReferencePosition(), rewrittenUri);
          } else {
            dynamicValue = (Expression) QuasiBuilder.substV(
                ""
                + "IMPORTS___./*@synthetic*/rewriteUriInAttribute___("
                + "    @value, @tagName, @attribName)",
View Full Code Here

    try {
      if (null == meta) {
        return null;
      }
      FetchedData data = meta.getUriFetcher().fetch(
          new ExternalReference(is.getUri(), FilePosition.UNKNOWN), "*/*");
      return data.getTextualContent();
    } catch (UriFetchException e) {
      e.printStackTrace();
      // Failed heuristic, return null
    } catch (UnsupportedEncodingException e) {
View Full Code Here

    OutputStreamWriter writer;
    try {
      writer = new OutputStreamWriter(response, Charsets.UTF_8);
      FetchedData result = uriFetcher.fetch(
        new ExternalReference(uri, uri, uri,
          FilePosition.startOfFile(new InputSource(uri))), "*/*");
      if (checker.check("text/css", result.getContentType()) ||
          checker.check("text/javascript", result.getContentType())) {
        renderAsJSON(
          result.getTextualContent().toString(),
View Full Code Here

TOP

Related Classes of com.google.caja.lexer.ExternalReference

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.