X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/043d29fd7eb72048cf5d07edfbc20ec5c25af708..527ec293c2cd84e777e8f05b4bdcf2b3b611a5e0:/app/helpers/browse_helper.rb diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index ef7b3f554..c4ce41b06 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -1,4 +1,4 @@ -require "uri" +require "cgi" module BrowseHelper def printable_name(object, version = false) @@ -99,7 +99,7 @@ module BrowseHelper private - ICON_TAGS = %w(aeroway amenity barrier building highway historic landuse leisure man_made natural railway shop tourism waterway).freeze + ICON_TAGS = %w[aeroway amenity barrier building highway historic landuse leisure man_made natural railway shop tourism waterway].freeze def icon_tags(object) object.tags.find_all { |k, _v| ICON_TAGS.include? k }.sort @@ -114,9 +114,9 @@ module BrowseHelper # the correct page. lookup_us = lookup.tr(" ", "_") - if page = WIKI_PAGES[locale][type][lookup_us] rescue nil + if page = WIKI_PAGES.dig(locale, type, lookup_us) url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}" - elsif page = WIKI_PAGES["en"][type][lookup_us] rescue nil + elsif page = WIKI_PAGES.dig("en", type, lookup_us) url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}" end @@ -151,7 +151,7 @@ module BrowseHelper # Must break it up to correctly build the url value = Regexp.last_match(1) section = "#" + Regexp.last_match(2) - encoded_section = "#" + URI.encode(Regexp.last_match(2).gsub(/ +/, "_"), /[^A-Za-z0-9:_]/).tr("%", ".") + encoded_section = "#" + CGI.escape(Regexp.last_match(2).gsub(/ +/, "_")).tr("%", ".") else section = "" encoded_section = ""