Checks to make sure that a user defined fixed url is valid

@param specNode
@param processedFixedUrls
@return
169540
protected boolean validateFixedUrl(final SpecNode specNode, final Set<String> processedFixedUrls) {
        boolean valid = true;

        if (!ProcessorConstants.VALID_FIXED_URL_PATTERN.matcher(specNode.getFixedUrl()).matches()) {
            log.error(format(ProcessorConstants.ERROR_FIXED_URL_NOT_VALID, specNode.getLineNumber(), specNode.getText()));
            valid = false;
        } else if (processedFixedUrls.contains(specNode.getFixedUrl())) {
            log.error(format(ProcessorConstants.ERROR_FIXED_URL_NOT_UNIQUE, specNode.getLineNumber(), specNode.getFixedUrl(),
                    specNode.getText()));
            valid = false;
        }

        return valid;
    }
661038
@Override
    public List<String> buildRequestUrl(final String resourceUri, final Endpoint endpoint) {
        LOGGER.debug("Processing: " + resourceUri);
        Objects.requireNonNull(resourceUri);
        try {
            final Optional<String> nonRdfSourceDescUri =
                    getNonRDFSourceDescribedByUri(resourceUri);
            if ( nonRdfSourceDescUri.isPresent() ) {
                return Collections.singletonList(nonRdfSourceDescUri.get());
            }
        } catch (final IOException ex) {
            throw new UncheckedIOException(ex);
        }
        return Collections.singletonList(resourceUri);
    }
660592
private static void handleWsRec(Node n, boolean normalize) {
        if (n instanceof CharacterData || n instanceof ProcessingInstruction) {
            String s = n.getNodeValue().trim();
            if (normalize) {
                s = normalize(s);
            }
            n.setNodeValue(s);
        }
        List<Node> toRemove = new LinkedList<Node>();
        for (Node child : new IterableNodeList(n.getChildNodes())) {
            handleWsRec(child, normalize);
            if (!(n instanceof Attr)
                && (child instanceof Text || child instanceof CDATASection)
                && child.getNodeValue().length() == 0) {
                toRemove.add(child);
            }
        }
        for (Node child : toRemove) {
            n.removeChild(child);
        }
        NamedNodeMap attrs = n.getAttributes();
        if (attrs != null) {
            final int len = attrs.getLength();
            for (int i = 0; i < len; i++) {
                handleWsRec(attrs.item(i), normalize);
            }
        }
    }
90172
static private void processHeredocStrings(SimpleNode node,
            List<StringProperty> strings) {

        // If there are any children, then process them in post-traversal order.
        int count = node.jjtGetNumChildren();
        if (count > 0) {
            for (int i = 0; i < count; i++) {
                SimpleNode n = (SimpleNode) node.jjtGetChild(i);

                // If this is a heredoc literal, then actually update the node
                // with the string.
                if (n instanceof ASTOperation) {
                    ASTOperation astop = (ASTOperation) n;
                    if (astop.getOperationType() == OperationType.HEREDOC) {

                        Operation op = astop.getOperation();
                        if (op instanceof LongProperty) {
                            LongProperty lprop = (LongProperty) op;
                            int index = lprop.getValue().intValue();
                            StringProperty sprop = strings.get(index);
                            astop.setOperationType(OperationType.LITERAL);
                            astop.setOperation(sprop);
                        } else {
                            throw new RuntimeException(
                                    "HEREDOC operation doesn't contain LongProperty");
                        }
                    }
                }

                // Alway process any children.
                processHeredocStrings(n, strings);
            }
        }
    }
280454
private Pattern parsePattern(Node node, Map<String, Scope> scopes) {
        List<PatternElement> elements = new ArrayList<PatternElement>();
        NodeList patternList = node.getChildNodes();
        int patternLength = patternList.getLength();
        if (patternLength <= 0) {
            throw new TextProcessorFactoryException("Invalid pattern. Pattern is empty.");
        }

        // Ignore case for all constants
        boolean ignoreCase = nodeAttribute(node, "ignoreCase", false);

        for (int k = 0; k < patternLength; k++) {
            Node el = patternList.item(k);
            short nodeType = el.getNodeType();

            if (nodeType == Node.TEXT_NODE) {
                elements.add(new Constant(el.getNodeValue(), ignoreCase));
            } else if (nodeType == Node.ELEMENT_NODE) {
                String tagName = el.getLocalName();
                if (tagName.equals(TAG_CONSTANT)) {
                    elements.add(parseConstant(el, ignoreCase));
                } else if (tagName.equals(TAG_VAR)) {
                    elements.add(parseNamedElement(el, scopes));
                } else if (tagName.equals(TAG_JUNK)) {
                    elements.add(new Junk());
                } else if (tagName.equals(TAG_EOL)) {
                    elements.add(parseEol(el));
                } else if (tagName.equals(TAG_BOL)) {
                    elements.add(new Bol());
                } else if (tagName.equals(TAG_BLANKLINE)) {
                    elements.add(new BlankLine(nodeAttribute(el, TAG_ATTR_GHOST, PatternElement.DEFAULT_GHOST_VALUE)));
                } else if (tagName.equals(TAG_URL)) {
                    elements.add(parseUrl(el));
                } else if (tagName.equals(TAG_EMAIL)){
                    elements.add(parseEmail(el));
                } else {
                    throw new TextProcessorFactoryException(
                            MessageFormat.format("Invalid pattern. Unknown XML element [{0}].", tagName)
                    );
                }
            } else {
                throw new TextProcessorFactoryException("Invalid pattern. Unsupported XML node type.");
            }
        }
        return new Pattern(elements);
    }
1199229
public boolean isMatchingTopic(String topic) {
		if (isFixedTopics()) {
			return getFixedTopics().contains(topic);
		} else {
			return topicPattern.matcher(topic).matches();
		}
	}
1183377
def is_valid_url(self, url, non_blocking=True):
        """"""
        logger.debug(str((url)))
        if non_blocking:
            method = self._is_valid_url
            return self._create_worker(method, url)
        else:
            return self._is_valid_url(url)
285323
protected void processLinkTag(LinkTag tag) {

        processLink(tag, ATTRIBUTE_HREF, CmsRelationType.valueOf(tag.getTagName()));
    }
1081393
@Override
    public SpecTopic getClosestTopic(final SpecTopic topic, final SpecNode callerNode, final boolean checkParentNode) {
        final SpecTopic retValue = super.getClosestTopic(topic, callerNode, checkParentNode);
        if (retValue != null) {
            return retValue;
        } else {
            // Look up the metadata topics
            final ContentSpec contentSpec = getContentSpec();
            for (final Node contentSpecNode : contentSpec.getNodes()) {
                if (contentSpecNode instanceof KeyValueNode && ((KeyValueNode) contentSpecNode).getValue() instanceof SpecTopic) {
                    final SpecTopic childTopic = (SpecTopic) ((KeyValueNode) contentSpecNode).getValue();
                    if (childTopic == topic || childTopic.getId().equals(topic.getId())) {
                        return childTopic;
                    }
                }
            }

            return null;
        }
    }
991558
@Override
    public boolean acceptsURL(String url) throws SQLException {

        if(url.startsWith(sqldroidPrefix) || url.startsWith(xerialPrefix)) {
            return true;
        }

        return false;
    }
1321325
function getProcessedUrl(data, resourceName) {
                        // get the raw URL out of the resource name and check if it is valid
                        var url = data[config.linksKey][resourceName][config.linksHrefKey];

                        if (url === undefined || !url) {
                            throw new Error('The provided resource name "' + resourceName + '" has no valid URL in the "' +
                                config.linksHrefKey + '" property.');
                        }

                        // extract the template parameters of the raw URL
                        return extractUrl(url, data[config.linksKey][resourceName].templated);
                    }
1062818
static Proxy parseProxySettings(String spec) {

        try {
            if (spec == null || spec.length() == 0) {
                return null;
            }
            return new Proxy(spec);
        } catch (URISyntaxException e) {
            return null;
        }
    }
847001
def parse_fixed(self, node):
        

        try:
            parameter = node.lattrib['parameter']
        except:
            self.raise_error('<Fixed> must specify a parameter to be fixed.')

        try:
            value = node.lattrib['value']
        except:
            self.raise_error("Fixed parameter '{0}'must specify a value.", parameter)

        description = node.lattrib.get('description', '')
        
        self.current_component_type.add_parameter(Fixed(parameter, value, description))
168011
function processProtectedElement( that, comment, protectedRegexs, filterOpts ) {
		var source = decodeURIComponent( comment.value.replace( /^\{cke_protected\}/, '' ) ),
			protectedFrag,
			toBeRemoved = [],
			node, i, match;

		// Protected element's and protected source's comments look exactly the same.
		// Check if what we have isn't a protected source instead of protected script/noscript.
		if ( protectedRegexs ) {
			for ( i = 0; i < protectedRegexs.length; ++i ) {
				if ( ( match = source.match( protectedRegexs[ i ] ) ) &&
					match[ 0 ].length == source.length	// Check whether this pattern matches entire source
														// to avoid '<script>alert("<? 1 ?>")</script>' matching
														// the PHP's protectedSource regexp.
				)
					return true;
			}
		}

		protectedFrag = CKEDITOR.htmlParser.fragment.fromHtml( source );

		if ( protectedFrag.children.length == 1 && ( node = protectedFrag.children[ 0 ] ).type == CKEDITOR.NODE_ELEMENT )
			processElement( that, node, toBeRemoved, filterOpts );

		// If protected element has been marked to be removed, return 'false' - comment was rejected.
		return !toBeRemoved.length;
	}
524442
private void verifyUrls(Set<CrawlerURL> allUrls, Set<HTMLPageResponse> verifiedUrls,
      Set<HTMLPageResponse> nonWorkingUrls, Map<String, String> requestHeaders) {

    Set<CrawlerURL> urlsThatNeedsVerification = new LinkedHashSet<CrawlerURL>(allUrls);

    urlsThatNeedsVerification.removeAll(verifiedUrls);

    final Set<Callable<HTMLPageResponse>> tasks =
        new HashSet<Callable<HTMLPageResponse>>(urlsThatNeedsVerification.size());

    for (CrawlerURL testURL : urlsThatNeedsVerification) {
      tasks.add(new HTMLPageResponseCallable(testURL, responseFetcher, true, requestHeaders, false));
    }

    try {
      // wait for all urls to verify
      List<Future<HTMLPageResponse>> responses = service.invokeAll(tasks);

      for (Future<HTMLPageResponse> future : responses) {
        if (!future.isCancelled()) {
          HTMLPageResponse response = future.get();
          if (response.getResponseCode() == HttpStatus.SC_OK
              && response.getResponseType().indexOf("html") > 0) {
            // remove, way of catching interrupted / execution e
            urlsThatNeedsVerification.remove(response.getPageUrl());
            verifiedUrls.add(response);
          } else if (response.getResponseCode() == HttpStatus.SC_OK) {
            // it is not HTML
            urlsThatNeedsVerification.remove(response.getPageUrl());
          } else {
            nonWorkingUrls.add(response);
          }
        }
      }

    } catch (InterruptedException e1) {
      // TODO add some logging
      e1.printStackTrace();
    } catch (ExecutionException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // TODO: We can have a delta here if the exception occur

  }
963300
private boolean validateExistingTopicTags(final ITopicNode topicNode, final BaseTopicWrapper<?> topic) {
        // Ignore validating revision topics
        if (topicNode.getRevision() != null) {
            return true;
        }

        boolean valid = true;
        final List<String> tagNames = topicNode.getTags(true);
        if (!tagNames.isEmpty()) {
            final Set<TagWrapper> tags = new HashSet<TagWrapper>();
            for (final String tagName : tagNames) {
                // Check if the app should be shutdown
                if (isShuttingDown.get()) {
                    shutdown.set(true);
                    return false;
                }
                // Get the tag from the database
                TagWrapper tag = null;
                try {
                    tag = tagProvider.getTagByName(tagName);
                } catch (NotFoundException e) {

                }

                // Check that it exists
                if (tag != null) {
                    tags.add(tag);
                }
            }

            // Add all the existing tags
            if (topic.getTags() != null) {
                tags.addAll(topic.getTags().getItems());
            }

            // Check that the mutex value entered is correct
            final Map<Integer, List<TagWrapper>> mapping = EntityUtilities.getCategoryMappingFromTagList(tags);
            for (final Entry<Integer, List<TagWrapper>> catEntry : mapping.entrySet()) {
                final CategoryWrapper cat = categoryProvider.getCategory(catEntry.getKey());
                final List<TagWrapper> catTags = catEntry.getValue();

                // Check if the app should be shutdown
                if (isShuttingDown.get()) {
                    shutdown.set(true);
                    return false;
                }

                // Check that only one tag has been set if the category is mutually exclusive
                if (cat.isMutuallyExclusive() && catTags.size() > 1) {
                    log.error(String.format(ProcessorConstants.ERROR_TOPIC_TOO_MANY_CATS_MSG, topicNode.getLineNumber(), cat.getName(),
                            topicNode.getText()));
                    valid = false;
                }
            }
        }
        return valid;
    }
130637
private static UriPart getNextUriPart(
      RawTextNode node, int offset, UriPart uriPart, char matchChar) {
    // This switch statement is designed to process a URI in order via a sequence of fall throughs.
    switch (uriPart) {
      case MAYBE_SCHEME:
      case MAYBE_VARIABLE_SCHEME:
        // From the RFC: https://tools.ietf.org/html/rfc3986#section-3.1
        // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
        // At this point, our goal is to try to prove that we've safely left the scheme, and then
        // transition to a more specific state.

        if (matchChar == ':') {
          // Ah, it looks like we might be able to conclude we've set the scheme, but...
          if (uriPart == UriPart.MAYBE_VARIABLE_SCHEME) {
            // At the start of a URL, and we already saw a print statement, and now we suddenly
            // see a colon. While this could be relatively safe if it's a {$host}:{$port} pair,
            // at compile-time, we can't be sure that "$host" isn't something like "javascript"
            // and "$port" isn't "deleteMyAccount()".
            throw SoyAutoescapeException.createWithNode(
                "Soy can't safely process a URI that might start with a variable scheme. "
                    + "For example, {$x}:{$y} could have an XSS if $x is 'javascript' and $y is "
                    + "attacker-controlled. Either use a hard-coded scheme, or introduce "
                    + "disambiguating characters (e.g. http://{$x}:{$y}, ./{$x}:{$y}, or "
                    + "{$x}?foo=:{$y})",
                node.substring(/* newId= */ Integer.MAX_VALUE, offset));
          } else {
            // At the start of the URL, and we just saw some hard-coded characters and a colon,
            // like http:. This is safe (assuming it's a good scheme), and now we're on our way to
            // the authority. Note if javascript: was seen, we would have scanned it already and
            // entered a separate state (unless the developer is malicious and tries to obscure it
            // via a conditional).
            return UriPart.AUTHORITY_OR_PATH;
          }
        }

        if (matchChar == '/') {
          // Upon seeing a slash, it's impossible to set a valid scheme anymore. Either we're in the
          // path, or we're starting a protocol-relative URI. (For all we know, we *could* be
          // in the query, e.g. {$base}/foo if $base has a question mark, but sadly we have to go
          // by what we know statically. However, usually query param groups tend to contain
          // ampersands and equal signs, which we check for later heuristically.)
          return UriPart.AUTHORITY_OR_PATH;
        }

        if ((matchChar == '=' || matchChar == '&') && uriPart == UriPart.MAYBE_VARIABLE_SCHEME) {
          // This case is really special, and is only seen in cases like href="{$x}&amp;foo={$y}" or
          // href="{$x}foo={$y}".  While in this case we can never be sure that we're in the query
          // part, we do know two things:
          //
          // 1) We can't possibly set a dangerous scheme, since no valid scheme contains = or &
          // 2) Within QUERY, all print statements are encoded as a URI component, which limits
          // the damage that can be done; it can't even break into another path segment.
          // Therefore, it is secure to assume this.
          //
          // Note we can safely handle ampersand even in HTML contexts because attribute values
          // are processed unescaped.
          return UriPart.QUERY;
        }
        // fall through
      case AUTHORITY_OR_PATH:
        // fall through
      case UNKNOWN_PRE_FRAGMENT:
        if (matchChar == '?') {
          // Upon a ? we can be pretty sure we're in the query. While it's possible for something
          // like {$base}?foo=bar to be in the fragment if $base contains a #, it's safe to assume
          // we're in the query, because query params are escaped more strictly than the fragment.
          return UriPart.QUERY;
        }
        // fall through
      case QUERY:
      case UNKNOWN:
        if (matchChar == '#') {
          // A # anywhere proves we're in the fragment, even if we're already in the fragment.
          return UriPart.FRAGMENT;
        }
        // fall through
      case FRAGMENT:
        // No transitions for fragment.
        return uriPart;
      case DANGEROUS_SCHEME:
        // Dangerous schemes remain dangerous.
        return UriPart.DANGEROUS_SCHEME;
      case TRUSTED_RESOURCE_URI_END:
        throw new AssertionError("impossible");
      case NONE:
        // generally impossible
      case START:
        // fall-through.  this should have been handled by our callers
    }
    throw new AssertionError("Unanticipated URI part: " + uriPart);
  }