Fix handling of keys containing colons (fixes #13)
This commit is contained in:
parent
2882bca483
commit
88f61bf7fa
@ -128,7 +128,7 @@ module RemoteStorage
|
|||||||
|
|
||||||
directory_entries(user, directory).each do |entry|
|
directory_entries(user, directory).each do |entry|
|
||||||
timestamp = DateTime.rfc2822(entry["last_modified"]).to_i
|
timestamp = DateTime.rfc2822(entry["last_modified"]).to_i
|
||||||
listing.merge!({ entry["name"] => timestamp })
|
listing.merge!({ CGI.unescape(entry["name"]) => timestamp })
|
||||||
end
|
end
|
||||||
|
|
||||||
listing
|
listing
|
||||||
@ -146,7 +146,8 @@ module RemoteStorage
|
|||||||
map_query = <<-EOH
|
map_query = <<-EOH
|
||||||
function(v){
|
function(v){
|
||||||
keys = v.key.split(':');
|
keys = v.key.split(':');
|
||||||
key_name = keys[keys.length-1];
|
keys.splice(0, 2);
|
||||||
|
key_name = keys.join(':');
|
||||||
last_modified_date = v.values[0]['metadata']['X-Riak-Last-Modified'];
|
last_modified_date = v.values[0]['metadata']['X-Riak-Last-Modified'];
|
||||||
return [{
|
return [{
|
||||||
name: key_name,
|
name: key_name,
|
||||||
|
@ -18,7 +18,7 @@ describe "Directories" do
|
|||||||
|
|
||||||
before do
|
before do
|
||||||
put "/jimmy/tasks/foo", "do the laundry"
|
put "/jimmy/tasks/foo", "do the laundry"
|
||||||
put "/jimmy/tasks/bar", "do the laundry"
|
put "/jimmy/tasks/http%3A%2F%2F5apps.com", "prettify design"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "lists the objects with a timestamp of the last modification" do
|
it "lists the objects with a timestamp of the last modification" do
|
||||||
@ -28,7 +28,7 @@ describe "Directories" do
|
|||||||
last_response.content_type.must_equal "application/json"
|
last_response.content_type.must_equal "application/json"
|
||||||
|
|
||||||
content = JSON.parse(last_response.body)
|
content = JSON.parse(last_response.body)
|
||||||
content.must_include "bar"
|
content.must_include "http://5apps.com"
|
||||||
content.must_include "foo"
|
content.must_include "foo"
|
||||||
content["foo"].to_s.must_match /\d+/
|
content["foo"].to_s.must_match /\d+/
|
||||||
content["foo"].to_s.length.must_be :>=, 10
|
content["foo"].to_s.length.must_be :>=, 10
|
||||||
@ -62,7 +62,7 @@ describe "Directories" do
|
|||||||
|
|
||||||
content = JSON.parse(last_response.body)
|
content = JSON.parse(last_response.body)
|
||||||
content.must_include "foo"
|
content.must_include "foo"
|
||||||
content.must_include "bar"
|
content.must_include "http://5apps.com"
|
||||||
content.must_include "home/"
|
content.must_include "home/"
|
||||||
content["home/"].to_s.must_match /\d+/
|
content["home/"].to_s.must_match /\d+/
|
||||||
content["home/"].to_s.length.must_be :>=, 10
|
content["home/"].to_s.length.must_be :>=, 10
|
||||||
|
@ -174,6 +174,19 @@ describe "App with Riak backend" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with escaped key" do
|
||||||
|
before do
|
||||||
|
put "/jimmy/documents/http%3A%2F%2F5apps.com", "super website"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "delivers the data correctly" do
|
||||||
|
header "Authorization", "Bearer 123"
|
||||||
|
get "/jimmy/documents/http%3A%2F%2F5apps.com"
|
||||||
|
|
||||||
|
last_response.body.must_equal 'super website'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "invalid JSON" do
|
context "invalid JSON" do
|
||||||
context "empty body" do
|
context "empty body" do
|
||||||
before do
|
before do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user