about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-11-11 10:47:16 +0000
committerEric Wong <normalperson@yhbt.net>2011-11-11 10:57:45 +0000
commit55de4a3375793fa31993a1e9b4be777007bd31b8 (patch)
tree700a4d8889c94a75632ea6d3110b979e2802512b
parent45f519f571cf88e1710e8175cff5742bed070ff9 (diff)
downloadmogilefs-client-55de4a3375793fa31993a1e9b4be777007bd31b8.tar.gz
url_unescape: fix ordering of "+" => " " of swap
Otherwise we'll be converting "%2B" into " " instead of
"+" when it appears in a file name.
-rw-r--r--lib/mogilefs/backend.rb2
-rw-r--r--test/test_mogilefs_integration_list_keys.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/mogilefs/backend.rb b/lib/mogilefs/backend.rb
index a56abf1..50272df 100644
--- a/lib/mogilefs/backend.rb
+++ b/lib/mogilefs/backend.rb
@@ -288,6 +288,6 @@ class MogileFS::Backend
 
   # Unescapes naughty URL characters.
   def url_unescape(str) # :nodoc:
-    str.gsub(/%([a-f0-9][a-f0-9])/i) { [$1.to_i(16)].pack 'C' }.tr('+', ' ')
+    str.tr('+', ' ').gsub(/%([a-f0-9][a-f0-9])/i) { [$1.to_i(16)].pack 'C' }
   end
 end
diff --git a/test/test_mogilefs_integration_list_keys.rb b/test/test_mogilefs_integration_list_keys.rb
index bb3f94a..6c62e6b 100644
--- a/test/test_mogilefs_integration_list_keys.rb
+++ b/test/test_mogilefs_integration_list_keys.rb
@@ -23,6 +23,12 @@ class TestMogileFSIntegrationListKeys < TestMogIntegration
     end
   end
 
+  def test_list_keys_strange
+    @client.store_content("hello+world", nil, "HI")
+    rv = @client.list_keys
+    assert_equal "hello+world", rv[0][0]
+  end
+
   def test_each_key
     9.times { |i| @client.store_content("ek_#{i}", nil, i.to_s) }
     n = 0