FIX: URL encode whitespace character globally

FIX: URL encode whitespace character globally

diff --git a/lib/onebox/engine/whitelisted_generic_onebox.rb b/lib/onebox/engine/whitelisted_generic_onebox.rb
index aeac85c..bb378c6 100644
--- a/lib/onebox/engine/whitelisted_generic_onebox.rb
+++ b/lib/onebox/engine/whitelisted_generic_onebox.rb
@@ -307,7 +307,7 @@ module Onebox
       end
 
       def card_html
-        escaped_url = ::Onebox::Helpers.normalize_url_for_output(data[:player].gsub(' ', '%20'))
+        escaped_url = ::Onebox::Helpers.normalize_url_for_output(data[:player])
 
         <<~RAW
         <iframe src="#{escaped_url}"
diff --git a/lib/onebox/helpers.rb b/lib/onebox/helpers.rb
index 7691b9d..cd7fbc7 100644
--- a/lib/onebox/helpers.rb
+++ b/lib/onebox/helpers.rb
@@ -164,6 +164,7 @@ module Onebox
       return "" unless url
       url = url.dup
       # expect properly encoded url, remove any unsafe chars
+      url.gsub!(' ', '%20')
       url.gsub!("'", "&apos;")
       url.gsub!('"', "&quot;")
       url.gsub!(/[^\w\-`.~:\/?#\[\]@!$&'\(\)*+,;=%]/, "")

GitHub sha: 4ec43267

1 Like