Occurrences don't handle fragments correctly
Opened this issue · 0 comments
pieter commented
URI::HTTP.build
takes fragments without a hash #
. I haven't investigated this thoroughly, but at least with IE 9.0, we store fragments with a leading #
, causing Occurrence#url
to throw an exception:
URI::InvalidComponentError: bad component(expected fragment component): #/dashboard/settings
from /usr/lib/ruby/1.9.1/uri/generic.rb:1000:in `check_fragment'
from /usr/lib/ruby/1.9.1/uri/generic.rb:1041:in `fragment='
from /usr/lib/ruby/1.9.1/uri/generic.rb:200:in `initialize'
from /usr/lib/ruby/1.9.1/uri/http.rb:84:in `initialize'
from /usr/lib/ruby/1.9.1/uri/generic.rb:140:in `new'
from /usr/lib/ruby/1.9.1/uri/generic.rb:140:in `build'
from /usr/lib/ruby/1.9.1/uri/http.rb:62:in `build'
from /home/squash/web/app/models/occurrence.rb:510:in `url'
I fixed it locally with this patch:
diff --git a/app/models/occurrence.rb b/app/models/occurrence.rb
index 20d075e..1cfb280 100644
--- a/app/models/occurrence.rb
+++ b/app/models/occurrence.rb
@@ -507,7 +507,7 @@ class Occurrence < ActiveRecord::Base
@url ||= begin
return nil unless web?
return nil unless URI.scheme_list.include?(schema.upcase)
- URI.scheme_list[schema.upcase].build(host: host, port: port, path: path, query: query, fragment: fragment)
+ URI.scheme_list[schema.upcase].build(host: host, port: port, path: path, query: query, fragment: fragment.sub(/^#/, ""))
end
end
But I'm not sure what the correct solution is for Squash -- perhaps we want to strip the leading #
when storing occurrences.