Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update URL Rerouting to encode brackets and escape non-ASCII in URI Encoding #320

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,9 @@
resources :shortlinks, except: :show

# Redirect to prot's subdomain, keeping the path and any extensions in the request
match '/mediawiki(/*path)', via: :all, to: redirect { |params, _| URI.encode("https://prot-hkn.eecs.berkeley.edu/w/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}") }
match '/prot(/*path)', via: :all, to: redirect { |params, _| URI.encode("https://prot-hkn.eecs.berkeley.edu/wiki/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}") }
match '/prot2(/*path)', via: :all, to: redirect { |params, _| URI.encode("https://prot-hkn.eecs.berkeley.edu/w/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}") }
match '/mediawiki(/*path)', via: :all, to: redirect { |params, _| URI.encode("https://prot-hkn.eecs.berkeley.edu/w/#{ URI.escape(params[:path]) }#{ '.' + URI.escape(params[:format]) if params[:format].present?}", "[]") }
match '/prot(/*path)', via: :all, to: redirect { |params, _| URI.encode("https://prot-hkn.eecs.berkeley.edu/wiki/#{ URI.escape(params[:path]) }#{ '.' + URI.escape(params[:format]) if params[:format].present?}", "[]") }
match '/prot2(/*path)', via: :all, to: redirect { |params, _| URI.encode("https://prot-hkn.eecs.berkeley.edu/w/#{ URI.escape(params[:path]) }#{ '.' + URI.escape(params[:format]) if params[:format].present?}", "[]") }

# Redirect some alumni sites that were discontinued but requested redirects to
# prevent any old links breaking
Expand All @@ -410,8 +410,8 @@
match '/~calbear/research.html', via: :all, to: redirect { "http://research.mbbaer.com/" }
match '/~calbear/research/', via: :all, to: redirect { "http://mbbaer.com/" }

match '/~chenm(/*path)', via: :all, to: redirect { |params, _| URI.encode("https://www.ocf.berkeley.edu/~morganjchen/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}") }
match '/~dyoo(/*path)', via: :all, to: redirect { |params, _| URI.encode("http://www.hashcollision.org/hkn/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}") }
match '/~chenm(/*path)', via: :all, to: redirect { |params, _| URI.encode("https://www.ocf.berkeley.edu/~morganjchen/#{ URI.escape(params[:path]) }#{ '.' + URI.escape(params[:format]) if params[:format].present?}", "[]") }
match '/~dyoo(/*path)', via: :all, to: redirect { |params, _| URI.encode("http://www.hashcollision.org/hkn/#{ URI.escape(params[:path]) }#{ '.' + URI.escape(params[:format]) if params[:format].present?}", "[]") }

# This section must remain at the bottom of the routes, since they are
# catch-all routes to enable arbitrary hierarchy and placement of static pages
Expand Down