Skip to content

Commit

Permalink
Check URIs against URI.regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Mar 11, 2016
1 parent 7f04fd9 commit f225277
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/lib/installation/clients/inst_update_installer.rb
Expand Up @@ -21,7 +21,6 @@ class InstUpdateInstaller < Client
include Yast::Logger

UPDATED_FLAG_FILENAME = "installer_updated"
URL_SUPPORTED_SCHEMES = ["http", "https", "ftp"]

Yast.import "Directory"
Yast.import "Installation"
Expand Down Expand Up @@ -82,25 +81,24 @@ def self_update_url
#
# @return [URI,nil] self-update URL. nil if no URL was set in Linuxrc.
def self_update_url_from_linuxrc
url = URI(Linuxrc.InstallInf("SelfUpdate") || "")
valid_url?(url) ? url : nil
url = Linuxrc.InstallInf("SelfUpdate") || ""
valid_url?(url) ? URI(url) : nil
end

# Return the self-update URL according to product's control file
#
# @return [URI,nil] self-update URL. nil if no URL was set in control file.
def self_update_url_from_control
url = URI(ProductFeatures.GetStringFeature("globals", "self_update_url"))
valid_url?(url) ? url : nil
url = ProductFeatures.GetStringFeature("globals", "self_update_url")
valid_url?(url) ? URI(url) : nil
end

# Determines whether the URL is valid or no
#
# @return [Boolean] True if it's valid; false otherwise.
#
# @see URL_SUPPORTED_SCHEMES
# @see URI.regexp
def valid_url?(url)
URL_SUPPORTED_SCHEMES.include?(url.scheme) ? url : false
URI.regexp.match(url)
end

# Check if installer was updated
Expand Down

0 comments on commit f225277

Please sign in to comment.