module Seahorse::Util
def escape_header_list_string(s)
def escape_header_list_string(s) s.include?('"') || s.include?(',') ? "\"#{s.gsub('"', '\"')}\"" : s end
def host_label?(str)
- See: https://tools.ietf.org/html/rfc1123#page-13 -
See: https://tools.ietf.org/html/rfc3986#section-3.2.2 -
def host_label?(str) str =~ /^(?!-)[a-zA-Z0-9-]{1,63}(?<!-)$/ end
def uri_escape(string)
def uri_escape(string) CGI.escape(string.to_s.encode('UTF-8')).gsub('+', '%20').gsub('%7E', '~') end
def uri_path_escape(path)
def uri_path_escape(path) path.gsub(/[^\/]+/) { |part| uri_escape(part) } end