Skip to content
This repository was archived by the owner on Feb 28, 2023. It is now read-only.

Commit 5f648e1

Browse files
committed
Do not use String#escapeHTML
1 parent f9c3045 commit 5f648e1

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

contrib/plugin/rast-search.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ def rast_output(s)
1212
title_str = @key.empty? ? @conf.msg_search : @conf.msg_search_result
1313
str = <<-EOS
1414
<form class="update" action="./">
15-
<h2>#{@conf.site_name.escapeHTML} - #{title_str.escapeHTML}</h2>
16-
<p>#{@conf.msg_search_comment.escapeHTML}</p>
17-
<p><input type="text" name="key" size="20" value="#{@key.escapeHTML}">
15+
<h2>#{h(@conf.site_name)} - #{h(title_str)}</h2>
16+
<p>#{h(@conf.msg_search_comment)}</p>
17+
<p><input type="text" name="key" size="20" value="#{h(@key)}">
1818
<input type="hidden" name="c" value="search">
19-
<input type="submit" name="search" value="#{@conf.msg_search.escapeHTML}"></p>
19+
<input type="submit" name="search" value="#{h(@conf.msg_search)}"></p>
2020
</form>
2121
EOS
2222
parser = @conf.parser::new(@conf)
@@ -47,13 +47,13 @@ def search
4747
options = create_search_options
4848
@result = db.search(@key, options)
4949
if @result.hit_count ==0
50-
rast_output("<p>#{(@conf.msg_search_not_found % @key).escapeHTML}</p>")
50+
rast_output("<p>#{h(@conf.msg_search_not_found % @key)}</p>")
5151
else
5252
rast_output(format_result)
5353
end
5454
end
5555
rescue
56-
rast_output("<p>Error : #{$!.message.escapeHTML}</p>")
56+
rast_output("<p>Error : #{h($!.message)}</p>")
5757
ensure
5858
rast_db_list.each do |db|
5959
db.close if db
@@ -63,18 +63,18 @@ def search
6363
end
6464

6565
def format_result
66-
head = "<p>#{(@conf.msg_search_hits % [@key, @db.page_info.size, @result.hit_count]).escapeHTML} (#{@start + 1} - #{@start + @result.items.size})</p>\n"
66+
head = "<p>#{h(@conf.msg_search_hits % [@key, @db.page_info.size, @result.hit_count])} (#{@start + 1} - #{@start + @result.items.size})</p>\n"
6767
ret = %Q(<dl class="search">\n)
6868
@result.items.each do |item|
6969
uri, title, last_modified = *item.properties
7070
title = uri if title.empty?
71-
summary = item.summary.escapeHTML || ''
71+
summary = h(item.summary) || ''
7272
for term in @result.terms
73-
summary.gsub!(Regexp.new(Regexp.quote(term.term.escapeHTML), true, "e"),
73+
summary.gsub!(Regexp.new(Regexp.quote(h(term.term)), true, "e"),
7474
"<strong>\\&</strong>")
7575
end
76-
ret << %Q|<dt><a href="#{uri.escapeHTML}">#{title.escapeHTML}</a></dt>\n|
77-
ret << %Q|<dd>#{summary}<br><a href="#{uri.escapeHTML}">#{uri.escapeHTML}</a></dd>\n|
76+
ret << %Q|<dt><a href="#{h(uri)}">#{h(title)}</a></dt>\n|
77+
ret << %Q|<dd>#{summary}<br><a href="#{h(uri)}">#{h(uri)}</a></dd>\n|
7878
end
7979
ret << "</dl>\n"
8080
head + ret + format_links

0 commit comments

Comments
 (0)