From e657fa4d56e2ce0566deea95ce14a73f6b4a8526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Kar=C3=A9kinian?= Date: Sun, 24 Nov 2013 17:10:07 +0100 Subject: [PATCH 1/6] Switch RubyGems source to https --- Gemfile | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 7b3146e..b8eb985 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source "http://rubygems.org" +source "https://rubygems.org" gem "sinatra" gem "sinatra-contrib" diff --git a/Gemfile.lock b/Gemfile.lock index 7358425..d1c2eb6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT multi_json (~> 1.0) GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: activesupport (3.2.13) i18n (= 0.6.1) From 9e6cc6178d024031a16ff64cedcc032a14fe7e82 Mon Sep 17 00:00:00 2001 From: Garret Alfert Date: Mon, 24 Feb 2014 17:43:43 +0100 Subject: [PATCH 2/6] Don't choke on colons in directory names (fixes #39) --- lib/remote_storage/riak.rb | 29 +++++++++++++++++------------ spec/directories_spec.rb | 12 ++++++++++++ spec/riak_spec.rb | 4 ++-- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/lib/remote_storage/riak.rb b/lib/remote_storage/riak.rb index 2ef3c39..248da41 100644 --- a/lib/remote_storage/riak.rb +++ b/lib/remote_storage/riak.rb @@ -270,14 +270,19 @@ module RemoteStorage map_query = <<-EOH function(v){ - keys = v.key.split(':'); - keys.splice(0, 2); - key_name = keys.join(':'); - last_modified_date = v.values[0]['metadata']['X-Riak-Last-Modified']; - timestamp = v.values[0]['metadata']['X-Riak-Meta']['X-Riak-Meta-Timestamp']; - etag = v.values[0]['metadata']['X-Riak-VTag']; + var metadata = v.values[0]['metadata']; + var dir_name = metadata['index']['directory_bin']; + if (dir_name === '/') { + dir_name = ''; + } + var name = v.key.match(/^[^:]*:(.*)/)[1]; // strip username from key + name = name.replace(dir_name + ':', ''); // strip directory from key + var last_modified_date = metadata['X-Riak-Last-Modified']; + var timestamp = metadata['X-Riak-Meta']['X-Riak-Meta-Timestamp']; + var etag = metadata['X-Riak-VTag']; + return [{ - name: key_name, + name: name, last_modified: last_modified_date, timestamp: timestamp, etag: etag @@ -294,12 +299,12 @@ module RemoteStorage map_query = <<-EOH function(v){ - keys = v.key.split(':'); - key_name = keys[keys.length-1]; - timestamp = v.values[0]['data']; - etag = v.values[0]['metadata']['X-Riak-VTag']; + var name = v.key.match(/^[^:]*:(.*)/)[1]; // strip username from key + var timestamp = v.values[0]['data']; + var etag = v.values[0]['metadata']['X-Riak-VTag']; + return [{ - name: key_name, + name: name, timestamp: timestamp, etag: etag }]; diff --git a/spec/directories_spec.rb b/spec/directories_spec.rb index 16124ea..dbe8a3e 100644 --- a/spec/directories_spec.rb +++ b/spec/directories_spec.rb @@ -17,6 +17,7 @@ describe "Directories" do before do put "/jimmy/tasks/foo", "do the laundry" put "/jimmy/tasks/http%3A%2F%2F5apps.com", "prettify design" + put "/jimmy/tasks/%3A/foo%3Abar%40foo.org", "hello world" end it "lists the objects with their version" do @@ -29,10 +30,21 @@ describe "Directories" do content = JSON.parse(last_response.body) content.must_include "http://5apps.com" + content.must_include ":/" content.must_include "foo" content["foo"].must_equal foo.etag.gsub(/"/, "") end + it "doesn't choke on colons in the directory name" do + get "/jimmy/tasks/%3A/" + + last_response.status.must_equal 200 + last_response.content_type.must_equal "application/json" + + content = JSON.parse(last_response.body) + content.must_include "foo:bar@foo.org" + end + it "has a Last-Modifier header set" do get "/jimmy/tasks/" diff --git a/spec/riak_spec.rb b/spec/riak_spec.rb index bc3ea04..65b1ec1 100644 --- a/spec/riak_spec.rb +++ b/spec/riak_spec.rb @@ -462,12 +462,12 @@ describe "App with Riak backend" do context "with escaped key" do before do - put "/jimmy/documents/http%3A%2F%2F5apps.com", "super website" + put "/jimmy/documents/bar%3Abaz/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" + get "/jimmy/documents/bar%3Abaz/http%3A%2F%2F5apps.com" last_response.body.must_equal 'super website' end From a6707dd40d853aa36926a9cf5fab7281718e1dbe Mon Sep 17 00:00:00 2001 From: Garret Alfert Date: Mon, 24 Feb 2014 20:44:23 +0100 Subject: [PATCH 3/6] Add spec for unescaped special characters --- spec/riak_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/riak_spec.rb b/spec/riak_spec.rb index 65b1ec1..fef3553 100644 --- a/spec/riak_spec.rb +++ b/spec/riak_spec.rb @@ -473,6 +473,25 @@ describe "App with Riak backend" do end end + context "with unescaped key" do + before do + put "/jimmy/documents/bar:baz/john@doe.com", "John Doe" + end + + it "lists the document in the directory" do + get "/jimmy/documents/bar:baz/" + + content = JSON.parse(last_response.body) + content.must_include "john@doe.com" + end + + it "delivers the data correctly" do + get "/jimmy/documents/bar:baz/john@doe.com" + + last_response.body.must_equal "John Doe" + end + end + context "escaped square brackets in key" do before do put "/jimmy/documents/gracehopper%5B1%5D.jpg", "super image" From 75bcc517f43eed5a49cecc54ef1e94f5b7c0f04e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Kar=C3=A9kinian?= Date: Wed, 19 Mar 2014 10:25:02 +0300 Subject: [PATCH 4/6] Update rainbows to 4.6.1 --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d1c2eb6..47543d1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -34,7 +34,7 @@ GEM formatador (0.2.4) i18n (0.6.1) innertube (1.0.2) - kgio (2.7.4) + kgio (2.9.2) m (1.2.1) method_source (>= 0.6.7) rake (>= 0.9.2.2, < 1.0.0) @@ -53,11 +53,11 @@ GEM rack rack-test (0.6.2) rack (>= 1.0) - rainbows (4.4.3) + rainbows (4.6.1) kgio (~> 2.5) rack (~> 1.1) - unicorn (~> 4.1) - raindrops (0.10.0) + unicorn (~> 4.8) + raindrops (0.13.0) rake (0.9.2.2) ruby-hmac (0.4.0) sinatra (1.4.3) @@ -72,7 +72,7 @@ GEM sinatra (~> 1.4.2) tilt (~> 1.3) tilt (1.4.1) - unicorn (4.3.1) + unicorn (4.8.2) kgio (~> 2.6) rack raindrops (~> 0.7) From 6fbb8cdcf4b208e21510cdfa20afc636532cd8cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Kar=C3=A9kinian?= Date: Fri, 9 May 2014 11:58:46 +0200 Subject: [PATCH 5/6] Update activesupport, i18n and nokogiri gems The old activesupport gem depended on i18n 0.6.1 --- Gemfile | 2 +- Gemfile.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index b8eb985..033ea19 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" gem "sinatra" gem "sinatra-contrib" -gem "activesupport" +gem "activesupport", '~> 3.2' gem "riak-client", :github => "5apps/riak-ruby-client", :branch => "invalid_uri_error" gem "fog" diff --git a/Gemfile.lock b/Gemfile.lock index 47543d1..c3a49fa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,8 +13,8 @@ GIT GEM remote: https://rubygems.org/ specs: - activesupport (3.2.13) - i18n (= 0.6.1) + activesupport (3.2.18) + i18n (~> 0.6, >= 0.6.4) multi_json (~> 1.0) backports (3.3.0) beefcake (0.3.7) @@ -32,7 +32,7 @@ GEM nokogiri (~> 1.5.0) ruby-hmac formatador (0.2.4) - i18n (0.6.1) + i18n (0.6.9) innertube (1.0.2) kgio (2.9.2) m (1.2.1) @@ -41,11 +41,11 @@ GEM method_source (0.8) mime-types (1.23) minitest (2.10.0) - multi_json (1.8.0) + multi_json (1.10.0) net-scp (1.0.4) net-ssh (>= 1.99.1) net-ssh (2.6.7) - nokogiri (1.5.10) + nokogiri (1.5.11) purdytest (1.0.0) minitest (~> 2.2) rack (1.5.2) @@ -81,7 +81,7 @@ PLATFORMS ruby DEPENDENCIES - activesupport + activesupport (~> 3.2) fog m purdytest From 7cbef2dee01eade8bfb1cc83defd9abbb42968e1 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Tue, 5 Aug 2014 12:20:25 +0200 Subject: [PATCH 6/6] Update gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 34387c2..ebb86ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ config.yml cs_credentials.json pids +.bundle +vendor/bundle