Skip to content

Commit 0f39ccc

Browse files
committed
Escape URL by ERB::Util.u. Hopefully fixes rails-taiwan#6 & railsbridge#353
1 parent 8119716 commit 0f39ccc

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/doc_page.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
require 'titleizer'
66
require 'html5_page'
77
require 'flags'
8+
require 'erb'
89

910
class DocPage < Html5Page
1011
needs :site_name, :doc_title, :doc_path, :page_name, :src, :locale
@@ -124,8 +125,8 @@ def body_content
124125
# Encode page name and fragment name separately so that
125126
# the fragment indicator '#' won't be escaped.
126127
page_name, fragment = @back.split('#')
127-
url_components = [URI.escape(page_name, URI::PATTERN::RESERVED)]
128-
url_components << URI.escape(fragment, URI::PATTERN::RESERVED) if fragment
128+
url_components = [ERB::Util.u(page_name)]
129+
url_components << ERB::Util.u(fragment) if fragment
129130
back_url = url_components.join('#')
130131

131132
div.back {

lib/step.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require 'markdown_renderer'
55
require 'titleizer'
66
require 'active_support/core_ext/string/strip'
7+
require 'erb'
78

89
class Step < Erector::Widget
910
external :style, <<-CSS
@@ -107,7 +108,7 @@ def link_without_toc name
107108
end
108109

109110
def _escaped str
110-
URI.escape(str, URI::PATTERN::RESERVED)
111+
ERB::Util.u(str)
111112
end
112113

113114
def simple_link name, options={}

0 commit comments

Comments
 (0)