Skip to content

Commit

Permalink
Code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Dec 6, 2022
1 parent 1ac66c4 commit ca17b69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package/yast2-add-on.changes
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-------------------------------------------------------------------
Mon Dec 5 17:37:00 UTC 2022 - Ladislav Slezák <lslezak@suse.cz>

- Fixed failure with CDATA URL containing white space in AutoYaST
profile (bsc#1205928)
- Fixed failure with the "media_url" element in AutoYaST profile
containing CDATA block with spaces (bsc#1205928)
- 4.4.8

-------------------------------------------------------------------
Expand Down
14 changes: 7 additions & 7 deletions src/lib/add-on/clients/add-on_auto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def import(data)
add_ons += data.fetch("add_on_others", [])

valid_add_ons = add_ons.reject.with_index(1) do |add_on, index|
next false unless addon_url(add_on).empty?
next false unless stripped_media_url(add_on).empty?

log.error("Missing <media_url> value in the #{index}. add-on definition")

Expand Down Expand Up @@ -91,7 +91,7 @@ def summary

add_on_summary = []
# TRANSLATORS: %s is an add-on URL
add_on_summary << _("URL: %s") % CGI.escapeHTML(addon_url(add_on))
add_on_summary << _("URL: %s") % CGI.escapeHTML(stripped_media_url(add_on))

if [nil, "", "/"].none?(product_dir)
# TRANSLATORS: %s is a product path
Expand Down Expand Up @@ -164,7 +164,7 @@ def export
def write
AddOnProduct.add_on_products.each do |add_on|
product = add_on.fetch("product", "")
media_url = media_url_for(add_on)
media_url = absolute_media_url(add_on)
action = create_source(add_on, product, media_url)

case action
Expand Down Expand Up @@ -208,7 +208,7 @@ def read
# Get URL for the addon
# @param add_on [Hash] the add on data
# @return [String] Addon URL or empty string if not set
def addon_url(add_on)
def stripped_media_url(add_on)
add_on.fetch("media_url", "").strip
end

Expand Down Expand Up @@ -266,8 +266,8 @@ def create_source(add_on, product, media_url)
# @param [Hash] add_on
#
# @return [String] absolute media url or empty string
def media_url_for(add_on)
media_url = addon_url(add_on)
def absolute_media_url(add_on)
media_url = stripped_media_url(add_on)

if media_url.downcase.start_with?("relurl://")
media_url = AddOnProduct.GetAbsoluteURL(AddOnProduct.GetBaseProductURL, media_url)
Expand Down Expand Up @@ -375,7 +375,7 @@ def preferred_name_for(add_on, repo)
# name in control file, bnc#433981
return add_on_name unless add_on_name.to_s.empty?

media_url = addon_url(add_on)
media_url = stripped_media_url(add_on)
product_dir = add_on.fetch("product_dir", "/")
expanded_url = Pkg.ExpandedUrl(media_url)
repos_at_url = Pkg.RepositoryScan(expanded_url) || []
Expand Down

0 comments on commit ca17b69

Please sign in to comment.