Skip to content

Commit

Permalink
Ruby: Fixed CodeQL polynomial regexp (#18699)
Browse files Browse the repository at this point in the history
  • Loading branch information
RiccardoPetteruti-Onfido authored May 19, 2024
1 parent e9f961e commit 8924083
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ module {{moduleName}}
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
end

# Deserialize the response to the given return type.
Expand Down Expand Up @@ -143,7 +143,7 @@ module {{moduleName}}
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
filename.split(/[\/\\]/).last
end

def build_request_url(path, opts = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def basic_auth(conn)
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
end

# Deserialize the response to the given return type.
Expand Down Expand Up @@ -328,7 +328,7 @@ def convert_to_type(data, return_type)
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
filename.split(/[\/\\]/).last
end

def build_request_url(path, opts = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def session
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
end

# Deserialize the response to the given return type.
Expand Down Expand Up @@ -267,7 +267,7 @@ def convert_to_type(data, return_type)
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
filename.split(/[\/\\]/).last
end

def build_request_url(path, opts = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def download_file(request)
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
end

# Deserialize the response to the given return type.
Expand Down Expand Up @@ -291,7 +291,7 @@ def convert_to_type(data, return_type)
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
filename.split(/[\/\\]/).last
end

def build_request_url(path, opts = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def download_file(request)
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
end

# Deserialize the response to the given return type.
Expand Down Expand Up @@ -291,7 +291,7 @@ def convert_to_type(data, return_type)
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
filename.split(/[\/\\]/).last
end

def build_request_url(path, opts = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def basic_auth(conn)
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
end

# Deserialize the response to the given return type.
Expand Down Expand Up @@ -328,7 +328,7 @@ def convert_to_type(data, return_type)
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
filename.split(/[\/\\]/).last
end

def build_request_url(path, opts = {})
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/ruby-httpx/lib/petstore/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def session
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
end

# Deserialize the response to the given return type.
Expand Down Expand Up @@ -267,7 +267,7 @@ def convert_to_type(data, return_type)
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
filename.split(/[\/\\]/).last
end

def build_request_url(path, opts = {})
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/ruby/lib/petstore/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def download_file(request)
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
end

# Deserialize the response to the given return type.
Expand Down Expand Up @@ -291,7 +291,7 @@ def convert_to_type(data, return_type)
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
filename.split(/[\/\\]/).last
end

def build_request_url(path, opts = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def download_file(request)
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
end

# Deserialize the response to the given return type.
Expand Down Expand Up @@ -291,7 +291,7 @@ def convert_to_type(data, return_type)
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
filename.split(/[\/\\]/).last
end

def build_request_url(path, opts = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def download_file(request)
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
end

# Deserialize the response to the given return type.
Expand Down Expand Up @@ -290,7 +290,7 @@ def convert_to_type(data, return_type)
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
filename.split(/[\/\\]/).last
end

def build_request_url(path, opts = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def download_file(request)
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
end

# Deserialize the response to the given return type.
Expand Down Expand Up @@ -290,7 +290,7 @@ def convert_to_type(data, return_type)
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
filename.gsub(/.*[\/\\]/, '')
filename.split(/[\/\\]/).last
end

def build_request_url(path, opts = {})
Expand Down

0 comments on commit 8924083

Please sign in to comment.