Makes sure that the given input is a sip URI.
559465
public static SanitizedContent filterSipUri(SoyValue value) {
    value = normalizeNull(value);
    return filterSipUri(value.coerceToString());
  }
48279
public String normalizeUri(String uri, boolean isWindows)
    throws IOException
  {
    CharBuffer cb = new CharBuffer();

    int len = uri.length();

    if (_maxURILength < len)
      throw new BadRequestException(L.l("The request contains an illegal URL because it is too long."));

    char ch;
    if (len == 0 || (ch = uri.charAt(0)) != '/' && ch != '\\')
      cb.append('/');

    for (int i = 0; i < len; i++) {
      ch = uri.charAt(i);

      if (ch == '/' || ch == '\\') {
      dots:
        while (i + 1 < len) {
          ch = uri.charAt(i + 1);

          if (ch == '/' || ch == '\\')
            i++;
          else if (ch != '.')
            break dots;
          else if (len <= i + 2
                   || (ch = uri.charAt(i + 2)) == '/' || ch == '\\') {
            i += 2;
          }
          else if (ch != '.')
            break dots;
          else if (len <= i + 3
                   || (ch = uri.charAt(i + 3)) == '/' || ch == '\\') {
            int j;

            for (j = cb.length() - 1; j >= 0; j--) {
              if ((ch = cb.charAt(j)) == '/' || ch == '\\')
                break;
            }
            if (j > 0)
              cb.length(j);
            else
              cb.length(0);
            i += 3;
          } else {
            throw new BadRequestException(L.l("The request contains an illegal URL."));
          }
        }

        while (isWindows && cb.length() > 0
               && ((ch = cb.lastChar()) == '.' || ch == ' ')) {
          cb.length(cb.length() - 1);

          if (cb.length() > 0
              && (ch = cb.lastChar()) == '/' || ch == '\\') {
            cb.length(cb.length() - 1);
            // server/003n
            continue;
          }
        }

        cb.append('/');
      }
      else if (ch == 0)
        throw new BadRequestException(L.l("The request contains an illegal URL."));
      else
        cb.append(ch);
    }

    while (isWindows && cb.length() > 0
           && ((ch = cb.lastChar()) == '.' || ch == ' ')) {
      cb.length(cb.length() - 1);
    }

    return cb.toString();
  }
1041813
function checkUri(i) {
  const start = i;
  let l;

  if (i >= tokensLength || tokens[i].value !== 'url') return 0;

  // Skip `url`.
  i++;

  if (i >= tokensLength || tokens[i].type !== TokenType.LeftParenthesis)
    return 0;

  // Store the opening parenthesis token as we will reference it's `right`
  // property to determine when the parentheses close
  const leftParenthesis = tokens[i];

  // Skip `(`.
  i++;

  // Determine the type of URI
  while (i < leftParenthesis.right) {
    if (l = checkUri1(i)) {
      i += l;
      tokens[start].uriType = 1; // Raw based URI (without quotes)
    } else if (l = checkUri2(i)) {
      i += l;
      tokens[start].uriType = 2; // Non-raw based URI (with quotes)
    } else return 0;
  }

  // Skip `)`.
  i++;

  return i - start;
}
618151
def validate_redirect_uri(value):
    
    sch, netloc, path, par, query, fra = urlparse(value)
    if not (sch and netloc):
        raise InvalidRedirectURIError()
    if sch != 'https':
        if ':' in netloc:
            netloc, port = netloc.split(':', 1)
        if not (netloc in ('localhost', '127.0.0.1') and sch == 'http'):
            raise InsecureTransportError()
1200203
private String ensureMinimalEscaping(String u, final String charset) {
        return ensureMinimalEscaping(u, charset, LaxURLCodec.EXPANDED_URI_SAFE);
    }
413599
private URI checkURI(String uri)
  {
    try
    {
      return new URI(Preconditions.checkNotNull(uri).trim());
    } catch (URISyntaxException e)
    {
      parser.getReport().message(MessageId.RSC_020, parser.getLocation(), uri);
      return null;
    }
  }
69005
def clean_iri(uri_string):
    ''''''
    uri_string = str(uri_string).strip()
    if uri_string[:1] == "<" and uri_string[len(uri_string)-1:] == ">":
        uri_string = uri_string[1:len(uri_string)-1]
    return uri_string
1151178
protected URI createUri(FileStatus i, UnixUserGroupInformation ugi,
      ClientProtocol nnproxy, HttpServletRequest request)
      throws IOException, URISyntaxException {
    return createUri(i.getPath().toString(),
        pickSrcDatanode(i, nnproxy), ugi, request);
  }
362812
def validate(self, uri):
		
		requirement = self.requirement()
		uri_component = uri.component(self.component())

		if uri_component is None:
			return requirement != WURIComponentVerifier.Requirement.required
		if requirement == WURIComponentVerifier.Requirement.unsupported:
			return False

		re_obj = self.re_obj()
		if re_obj is not None:
			return re_obj.match(uri_component) is not None
		return True
1221917
function checkUri(i) {
  const start = i;

  if (i >= tokensLength || tokens[i++].value !== 'url' ||
      i >= tokensLength || tokens[i].type !== TokenType.LeftParenthesis)
    return 0;

  return tokens[i].right - start + 1;
}
621014
private static void validateCreation(String method, SipApplicationSession app) {

		if (method.equals(Request.ACK)) {
			throw new IllegalArgumentException(
					"Wrong method to create request with[" + Request.ACK + "]!");
		}
		if (method.equals(Request.PRACK)) {
			throw new IllegalArgumentException(
					"Wrong method to create request with[" + Request.PRACK + "]!");
		}
		if (method.equals(Request.CANCEL)) {
			throw new IllegalArgumentException(
					"Wrong method to create request with[" + Request.CANCEL
							+ "]!");
		}
		if (!((MobicentsSipApplicationSession)app).isValidInternal()) {
			throw new IllegalArgumentException(
					"Cant associate request with invalidaded sip session application!");
		}

	}
852387
def validate_resource_uri(self, path):
        """"""
        if self._base_uri not in path:
            logger.exception('Get by uri : unrecognized uri: (%s)' % path)
            raise exceptions.HPOneViewUnknownType(UNRECOGNIZED_URI)
905159
private static void handleOrphanRequest(final SipProvider sipProvider,
			final SipServletRequestImpl sipServletRequest,
			String applicationId, final SipContext sipContext)
			throws DispatcherException {
		final String applicationName = sipContext.getApplicationName();
		final Request request = (Request) sipServletRequest.getMessage();
		
		// Making sure to nullify those ref so that if there is a race condition as in 
		// http://code.google.com/p/mobicents/issues/detail?id=2937
		// we return null instead of the invalidated sip application session
		sipServletRequest.setSipSession(null);
		sipServletRequest.setSipSessionKey(null);		
		sipServletRequest.setOrphan(true);
		sipServletRequest.setAppSessionId(applicationId);
		sipServletRequest.setCurrentApplicationName(applicationName);
		try {
			MessageDispatcher.callServletForOrphanRequest(sipContext, sipServletRequest);
			try {
				String transport = JainSipUtils.findTransport(request);
				SipConnector connector = StaticServiceHolder.sipStandardService.findSipConnector(transport);
				
				String branch = ((ViaHeader)sipServletRequest.getMessage().getHeader(ViaHeader.NAME)).getBranch();
				ViaHeader via = JainSipUtils.createViaHeader(sipContext.getSipApplicationDispatcher().getSipNetworkInterfaceManager(), request, 
						JainSipUtils.createBranch("orphan", 
								sipContext.getSipApplicationDispatcher().getHashFromApplicationName(applicationName),
								Integer.toString(branch.hashCode()) + branch.substring(branch.length()/2)), 
								null) ;
				if(connector.isUseStaticAddress()) {
					try {
						via.setHost(connector.getStaticServerAddress());
						via.setPort(connector.getStaticServerPort());
					} catch (Exception e) {
						throw new RuntimeException(e);
					}
					
				}
				sipServletRequest.getMessage().addHeader(via);

				sipProvider.sendRequest((Request) sipServletRequest.getMessage());
				sipContext.getSipApplicationDispatcher().updateRequestsStatistics(request, false);
			} catch (SipException e) {
				logger.error("Error routing orphaned request" ,e);
			}
			return;
		} catch (ServletException e) {
			throw new DispatcherException(Response.SERVER_INTERNAL_ERROR, "An unexpected servlet exception occured while processing the following subsequent request " + request, e);
		} catch (IOException e) {				
			throw new DispatcherException(Response.SERVER_INTERNAL_ERROR, "An unexpected servlet exception occured while processing the following subsequent request " + request, e);
		}
	}
379320
def _ingest_string(self, input_string, path_to_root):

        '''
            
        '''

        valid_string = ''

        try:
            valid_string = self._validate_string(input_string, path_to_root)
        except:
            rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_root)
            if 'default_value' in self.keyMap[rules_path_to_root]:
                valid_string = self.keyMap[rules_path_to_root]['default_value']

        return valid_string
256813
@Override
	public Request createRequest(Request origRequest) throws SipException {
		Request request = super.createRequest(origRequest);
        if (wrappedDialog == null) {
			// hack uri and address headers
			final SIPRequest sipRequest = (SIPRequest) request;
			final SleeSipProviderImpl provider = ra.getProviderWrapper();
			final HeaderFactory headerFactory = provider.getHeaderFactory();
			try {
				// hack request with local addresses
				final URI requestURI = (URI) toAddress.getURI().clone();
				if(requestURI.isSipURI()) {
					((SipUri)requestURI).clearUriParms();					
				}
				sipRequest.setRequestURI(requestURI);
				final FromHeader fromHeader = headerFactory.createFromHeader(
						fromAddress, getLocalTag());
				sipRequest.setFrom(fromHeader);
				final ToHeader toHeader = headerFactory.createToHeader(
						toAddress, null);
				sipRequest.setTo(toHeader);
			} catch (Exception e) {
				throw new SipException(e.getMessage(), e);
			}
		}
		return request;
	}
213948
public static boolean validateResource(String uriString) {
        if(uriString == null) {
            return false;
        }

        try {
            return validateResource(createUri(uriString));
        } catch(DataSourceException e) {
            Log.d(TAG, "URI is not valid", e);
            return false;
        }
    }
31875
private static boolean isValidFileSystemUri(URI uri) {
    // would like to just check null, but fragment appears to be the empty string when not present
    return isNullOrEmpty(uri.getPath())
        && isNullOrEmpty(uri.getQuery())
        && isNullOrEmpty(uri.getFragment());
  }