From 51647123f2c7f65843e36dd8b41f4558758e8139 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Fri, 5 Oct 2018 00:28:51 +0200 Subject: [PATCH] Allow fetching of posts with dot in the GUID --- config/routes.rb | 2 +- spec/routing/fetch_routing_spec.rb | 35 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 spec/routing/fetch_routing_spec.rb diff --git a/config/routes.rb b/config/routes.rb index 5e7086f..30c1a98 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,7 +5,7 @@ DiasporaFederation::Engine.routes.draw do end controller :fetch do - get "fetch/:type/:guid" => :fetch, :as => "fetch" + get "fetch/:type/:guid" => :fetch, :as => "fetch", :guid => /#{Validation::Rule::Guid::VALID_CHARS}/ end controller :webfinger do diff --git a/spec/routing/fetch_routing_spec.rb b/spec/routing/fetch_routing_spec.rb new file mode 100644 index 0000000..e8c50fe --- /dev/null +++ b/spec/routing/fetch_routing_spec.rb @@ -0,0 +1,35 @@ +module DiasporaFederation + describe ReceiveController, type: :routing do + routes { DiasporaFederation::Engine.routes } + + let(:guid) { "12345678901234567890abcdefgh" } + + it "routes post fetch" do + expect(get: "/fetch/post/#{guid}").to route_to( + controller: "diaspora_federation/fetch", + action: "fetch", + type: "post", + guid: guid + ) + end + + it "routes post fetch" do + expect(get: "/fetch/status_message/#{guid}").to route_to( + controller: "diaspora_federation/fetch", + action: "fetch", + type: "status_message", + guid: guid + ) + end + + it "routes post fetch with GUID with dots (hubzilla)" do + guid = "1234567890abcd@hubzilla.example.org" + expect(get: "/fetch/post/#{guid}").to route_to( + controller: "diaspora_federation/fetch", + action: "fetch", + type: "post", + guid: guid + ) + end + end +end