Strip HTTP transport implementation details so they don't leak via metadata into
the application layer.
968592
private static void stripTransportDetails(Metadata metadata) {
    metadata.discardAll(HTTP2_STATUS);
    metadata.discardAll(InternalStatus.CODE_KEY);
    metadata.discardAll(InternalStatus.MESSAGE_KEY);
  }
816398
private void cleanupDecBuffers() {
        // if we have decrypted buffers and they are either JIT created or made
        // during decryption/expansion (user buffers too small) then release them
        // here and dereference
        if (null != this.decryptedNetBuffers
            && (callerRequiredAllocation || decryptedNetBufferReleaseRequired)) {
            WsByteBufferUtils.releaseBufferArray(this.decryptedNetBuffers);
            this.decryptedNetBuffers = null;
        }
    }
74677
def deleteMetadata(self, remote, address, key):
        """"""
        try:
            return self.proxies["%s-%s" % (self._interface_id, remote)].deleteMetadata(address, key)
        except Exception as err:
            LOG.debug("ServerThread.deleteMetadata: Exception: %s" % str(err))
775623
def _sanitize_request_params(self, request_params):
        """"""
        if 'verify_ssl' in request_params:
            request_params['verify'] = request_params.pop('verify_ssl')
        return dict((key, val) for key, val in request_params.items()
                    if key in self._VALID_REQUEST_ARGS)
255773
def _cleanup(self) -> None:
        """"""
        if self._cleanup_handle:
            self._cleanup_handle.cancel()

        now = self._loop.time()
        timeout = self._keepalive_timeout

        if self._conns:
            connections = {}
            deadline = now - timeout
            for key, conns in self._conns.items():
                alive = []
                for proto, use_time in conns:
                    if proto.is_connected():
                        if use_time - deadline < 0:
                            transport = proto.transport
                            proto.close()
                            if (key.is_ssl and
                                    not self._cleanup_closed_disabled):
                                self._cleanup_closed_transports.append(
                                    transport)
                        else:
                            alive.append((proto, use_time))

                if alive:
                    connections[key] = alive

            self._conns = connections

        if self._conns:
            self._cleanup_handle = helpers.weakref_handle(
                self, '_cleanup', timeout, self._loop)
475191
def _clean_url(url):
    ''' 

    '''
    if url == 'default':
        url = DEFAULT_SERVER_HTTP_URL

    if url.startswith("ws"):
        raise ValueError("url should be the http or https URL for the server, not the websocket URL")

    return url.rstrip("/")
1329035
function stripFileProtocol (url) {
  var isFileUrl = url.substr(0, 7).toLowerCase() === 'file://';

  if (isFileUrl) {
    // Strip-off the protocol, and the initial "/", if there is one
    url = url[7] === '/' ? url.substr(8) : url.substr(7);

    if (isWindows) {
      // Insert a colon (":") after the drive letter, if necessary
      if (url[1] === '/') {
        url = url[0] + ':' + url.substr(1);
      }
    }
    else {
      // It's a Posix path, so start at root
      url = '/' + url;
    }
  }

  return url;
}
621603
public void removeRequestUrlAndParameters(HttpServletRequest request, HttpServletResponse response) {
        ReferrerURLCookieHandler referrerURLCookieHandler = getCookieHandler();
        referrerURLCookieHandler.invalidateReferrerURLCookie(request, response, ReferrerURLCookieHandler.REFERRER_URL_COOKIENAME);

        WebAppSecurityConfig webAppSecConfig = getWebAppSecurityConfig();
        if (isPostDataSavedInCookie(webAppSecConfig)) {
            deleteCookie(request, response, PostParameterHelper.POSTPARAM_COOKIE, webAppSecConfig);
        } else {
            removePostParameterSessionAttributes(request);
        }
    }
1063867
def clean_security_hash(self):
        """"""
        security_hash_dict = {
            'content_type': self.data.get("content_type", ""),
            'object_pk': self.data.get("object_pk", ""),
            'timestamp': self.data.get("timestamp", ""),
        }
        expected_hash = self.generate_security_hash(**security_hash_dict)
        actual_hash = self.cleaned_data["security_hash"]
        if not constant_time_compare(expected_hash, actual_hash):
            raise forms.ValidationError("Security hash check failed.")
        return actual_hash
245139
def sanitize(self):
        '''
        
        '''
        # Let the parent do its stuff
        super(Protocol, self).sanitize()

        # Check if the next header is of the right type, and fix this header
        # if we know better (i.e. the payload is a ProtocolElement so we know
        # the header_type)
        if isinstance(self.payload, Protocol):
            self.next_header = self.payload.header_type
1258292
void recycle(HttpConnection connection)
    {
        _method = null;
        //_uri=null;
        _host = null;
        _hostPort = null;
        _port = 0;
        _te = null;
        if (_parameters != null) _parameters.clear();
        _paramsExtracted = false;
        _handled = false;
        _cookiesExtracted = false;
        _timeStamp = 0;
        _timeStampStr = null;
        _authUser = null;
        _authType = null;
        _userPrincipal = null;
        super.recycle(connection);
    }
524876
def sanitize(self):
        '''
        
        '''
        # Let the parent do its stuff
        super(IPv4Packet, self).sanitize()

        # Check the version
        if self.version != 4:
            raise ValueError("Protocol version must be 4")

        # Treat type-of-service as an 8-bit unsigned integer. Future versions
        # of this code may implement methods to treat it as DSCP+ECN
        if not isinstance(self.tos, numbers.Integral) \
        or self.tos < 0 \
        or self.tos >= 2 ** 8:
            raise ValueError('Invalid type of service')

        # Identification: An identifying value assigned by the sender to aid in
        # assembling the fragments of a datagram.
        if not isinstance(self.identification, numbers.Integral) \
        or self.identification < 0 \
        or self.identification >= 2 ** 16:
            raise ValueError('Invalid fragment identification')

        # An internet datagram can be marked "don't fragment."  Any internet
        # datagram so marked is not to be internet fragmented under any
        # circumstances.  If internet datagram marked don't fragment cannot be
        # delivered to its destination without fragmenting it, it is to be
        # discarded instead.
        if not isinstance(self.dont_fragment, bool):
            raise ValueError("Don't fragment flag must be a boolean")

        # The More Fragments flag bit (MF) is set if the datagram is not the
        # last fragment.  The Fragment Offset field identifies the fragment
        # location, relative to the beginning of the original unfragmented
        # datagram.  Fragments are counted in units of 8 octets.  The
        # fragmentation strategy is designed so than an unfragmented datagram
        # has all zero fragmentation information (MF = 0, fragment offset =
        # 0).  If an internet datagram is fragmented, its data portion must be
        # broken on 8 octet boundaries.
        if not isinstance(self.more_fragments, bool):
            raise ValueError('More fragments flag must be a boolean')

        # Fragment offset: This field indicates where in the datagram this
        # fragment belongs. The fragment offset is measured in units of 8
        # octets (64 bits).  The first fragment has offset zero.
        if not isinstance(self.fragment_offset, numbers.Integral) \
        or self.fragment_offset < 0 \
        or self.fragment_offset >= 2 ** 13:
            raise ValueError('Invalid fragment offset')

        # Check for don't-fragment combined with a fragment offset
        if self.dont_fragment and self.fragment_offset > 0:
            raise ValueError("A packet marked don't fragment can't have "
                             "a fragment-offset")

        # Check that the TTL is correct
        if not isinstance(self.ttl, numbers.Integral) \
        or self.ttl < 0 \
        or self.ttl >= 2 ** 8:
            raise ValueError('Invalid TTL')

        # Check the source and destination addresses
        if not isinstance(self.source, IPv4Address):
            raise ValueError('Source address must be IPv4')

        if not isinstance(self.destination, IPv4Address):
            raise ValueError('Destination address must be IPv4')
1138077
private String parseDestinationHeader(HttpServletRequest req) {

        // Parsing destination header
        String destinationPath = req.getHeader(HEADER_DESTINATION);

        if (destinationPath == null) {
            return null;
        }

        // Remove url encoding from destination
        destinationPath = CmsEncoder.decode(destinationPath, "UTF8");

        int protocolIndex = destinationPath.indexOf("://");
        if (protocolIndex >= 0) {

            // if the Destination URL contains the protocol, we can safely
            // trim everything upto the first "/" character after "://"
            int firstSeparator = destinationPath.indexOf("/", protocolIndex + 4);
            if (firstSeparator < 0) {
                destinationPath = "/";
            } else {
                destinationPath = destinationPath.substring(firstSeparator);
            }
        } else {
            String hostName = req.getServerName();
            if ((hostName != null) && (destinationPath.startsWith(hostName))) {
                destinationPath = destinationPath.substring(hostName.length());
            }

            int portIndex = destinationPath.indexOf(":");
            if (portIndex >= 0) {
                destinationPath = destinationPath.substring(portIndex);
            }

            if (destinationPath.startsWith(":")) {
                int firstSeparator = destinationPath.indexOf("/");
                if (firstSeparator < 0) {
                    destinationPath = "/";
                } else {
                    destinationPath = destinationPath.substring(firstSeparator);
                }
            }
        }

        // Normalise destination path (remove '.' and '..')
        destinationPath = normalize(destinationPath);

        String contextPath = req.getContextPath();
        if ((contextPath != null) && (destinationPath.startsWith(contextPath))) {
            destinationPath = destinationPath.substring(contextPath.length());
        }

        String pathInfo = req.getPathInfo();
        if (pathInfo != null) {
            String servletPath = req.getServletPath();
            if ((servletPath != null) && (destinationPath.startsWith(servletPath))) {
                destinationPath = destinationPath.substring(servletPath.length());
            }
        }

        return destinationPath;
    }
1159713
def _strip_schema(url):
    """"""
    result = parse_url(url, allow_fragments=False)
    return result.netloc + result.path
955974
function stripConnectionHeaders(req) {
  var conn = req.getHeader("connection");
  if (typeof(conn) === 'undefined' || conn === null)
    return;

  conn.split(/\s+/g).forEach(function(header) {
    if (header.length === 0)
      return;
    req.removeHeader(header);
  });
  req.removeHeader("connection");
}
978469
private void removePropertyStrings(Service s) {
        String type = s.getType();
        String algorithm = s.getAlgorithm();
        // use super() to avoid permission check and other processing
        super.remove(type + "." + algorithm);
        for (String alias : s.getAliases()) {
            super.remove(ALIAS_PREFIX + type + "." + alias);
        }
        for (Map.Entry<UString,String> entry : s.attributes.entrySet()) {
            String key = type + "." + algorithm + " " + entry.getKey();
            super.remove(key);
        }
        if (registered) {
          Security.increaseVersion();
        }
    }
85160
def strip_system_metadata(etree_obj):
    
    for series_id_el in etree_obj.findall('seriesId'):
        etree_obj.remove(series_id_el)
    for media_type_el in etree_obj.findall('mediaType'):
        etree_obj.remove(media_type_el)
    for file_name_el in etree_obj.findall('fileName'):
        etree_obj.remove(file_name_el)