lib/gitlab/url_blocker.rb
# Validates the given url according to the constraints specified by arguments.
#
# ports - Raises error if the given URL port does is not between given ports.
# allow_localhost - Raises error if URL resolves to a localhost IP address and argument is false.
# allow_local_network - Raises error if URL resolves to a link-local address and argument is false.
# allow_object_storage - Avoid raising an error if URL resolves to an object storage endpoint and argument is true.
# ascii_only - Raises error if URL has unicode characters and argument is true.
# enforce_user - Raises error if URL user doesn't start with alphanumeric characters and argument is true.
# enforce_sanitization - Raises error if URL includes any HTML/CSS/JS tags and argument is true.
#
# Returns an array with [<uri>, <original-hostname>].
# rubocop:disable Metrics/ParameterLists
Validates the given url according to the constraints specified by arguments.
ports - Raises error if the given URL port does is not between given ports.
allow_localhost - Raises error if URL resolves to a localhost IP address and argument is false.
allow_local_network - Raises error if URL resolves to a link-local address and argument is false.
allow_object_storage - Avoid raising an error if URL resolves to an object storage endpoint and argument is true.
ascii_only - Raises error if URL has unicode characters and argument is true.
enforce_user - Raises error if URL user doesn't start with alphanumeric characters and argument is true.
enforce_sanitization - Raises error if URL includes any HTML/CSS/JS tags and argument is true.

Returns an array with [, ].
Validates the given url according to the constraints specified by arguments . ports - Raises error if the given URL port does is not between given ports . allow_localhost - Raises error if URL resolves to a localhost IP address and argument is false . allow_local_network - Raises error if URL resolves to a link - local address and argument is false . allow_object_storage - Avoid raising an error if URL resolves to an object storage endpoint and argument is true . ascii_only - Raises error if URL has unicode characters and argument is true . enforce_user - Raises error if URL user doesn ' t start with alphanumeric characters and argument is true . enforce_sanitization - Raises error if URL includes any HTML / CSS / JS tags and argument is true . Returns an array with [ ] .
def validate_uri(uri:, schemes:, ports:, enforce_sanitization:, enforce_user:, ascii_only:)
        validate_html_tags(uri) if enforce_sanitization
        return if internal?(uri)
        validate_scheme(uri.scheme, schemes)
        validate_port(get_port(uri), ports) if ports.any?
        validate_user(uri.user) if enforce_user
        validate_hostname(uri.hostname)
        validate_unicode_restriction(uri) if ascii_only
      end
def validate_uri ( uri : , schemes : , ports : , enforce_sanitization : , enforce_user : , ascii_only : ) validate_html_tags ( uri ) if enforce_sanitization return if internal? ( uri ) validate_scheme ( uri . scheme , schemes ) validate_port ( get_port ( uri ) , ports ) if ports . any? validate_user ( uri . user ) if enforce_user validate_hostname ( uri . hostname ) validate_unicode_restriction ( uri ) if ascii_only end
Validates the given url according to the constraints specified by arguments.
Validates the given url according to the constraints specified by arguments .
uri
<not_specific>
schemes
<not_specific>
ports
<not_specific>
enforce_sanitization
<not_specific>
enforce_user
<not_specific>
ascii_only
<not_specific>