File tree Expand file tree Collapse file tree 4 files changed +24
-10
lines changed Expand file tree Collapse file tree 4 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -503,7 +503,7 @@ def description_or_story_text(chars = 0)
503503 s = s . to_s [ 0 , chars ] . gsub ( / [^ ]*\z / , "" )
504504 end
505505
506- HTMLEntities . new . decode ( s . to_s )
506+ HtmlEncoder . encode ( s . to_s )
507507 end
508508
509509 def domain_search_url
Original file line number Diff line number Diff line change 11< ?xml version="1.0" encoding="UTF-8" ?>
2- <% coder = HTMLEntities . new %>
32< rss version ="2.0 ">
43 < channel >
54 < title > <%= Rails . application . name %> <%= @title . present? ?
98
109 <% @comments . each do |comment | %>
1110 < item >
12- < title > on <%= raw coder . encode ( comment . story . title , :decimal ) %> </ title >
11+ < title > on <%= raw HtmlEncoder . encode ( comment . story . title ) %> </ title >
1312 < link > <%= comment . url %> </ link >
1413 < guid > <%= comment . short_id_url %> </ guid >
1514 < author > <%= comment . user . username %> @users.<%= Rails . application . domain %> (<%= comment . user . username %> )</ author >
1615 < pubDate > <%= comment . created_at . rfc2822 %> </ pubDate >
1716 < comments > <%= comment . url %> </ comments >
18- < description > <%= raw coder . encode ( comment . markeddown_comment ,
19- :decimal ) %> </ description >
17+ < description > <%= raw HtmlEncoder . encode ( comment . markeddown_comment ) %> </ description >
2018 </ item >
2119 <% end %>
2220 </ channel >
Original file line number Diff line number Diff line change 11< ?xml version="1.0" encoding="UTF-8"?>
2- <% coder = HTMLEntities . new %>
32< rss version ="2.0 " xmlns:atom ="http://www.w3.org/2005/Atom ">
43 < channel >
54 < title > <%= Rails . application . name %> <%= @title . present? ?
109
1110 <% @stories . each do |story | %>
1211 < item >
13- < title > <%= raw coder . encode ( story . title , :decimal ) %> </ title >
12+ < title > <%= raw HtmlEncoder . encode ( story . title ) %> </ title >
1413 < link > <%= story . url_or_comments_url %> </ link >
1514 < guid isPermaLink ="false "> <%= story . short_id_url %> </ guid >
1615 < author > <%= story . user . username %> @users.<%= Rails . application . domain %> (<%= story . user . username %> )</ author >
1716 < pubDate > <%= story . created_at . rfc2822 %> </ pubDate >
1817 < comments > <%= story . comments_url %> </ comments >
1918 < description >
20- <%= raw coder . encode ( story . markeddown_description , :decimal ) %>
19+ <%= raw HtmlEncoder . encode ( story . markeddown_description ) %>
2120 <% if story . url . present? %>
22- <%= raw coder . encode ( "<p>" +
23- link_to ( "Comments" , story . comments_url ) + "</p>" , :decimal ) %>
21+ <%= raw HtmlEncoder . encode ( "<p>" +
22+ link_to ( "Comments" , story . comments_url ) + "</p>" ) %>
2423 <% end %>
2524 </ description >
2625 <% story . taggings . each do |tagging | %>
Original file line number Diff line number Diff line change 1+ # typed: false
2+
3+ require "cgi"
4+
5+ module HtmlEncoder
6+ HTML_ENTITIES = HTMLEntities . new
7+
8+ class << self
9+ def encode ( string , type = :decimal )
10+ HTML_ENTITIES . encode ( string , type )
11+ end
12+
13+ def decode ( encoded_string )
14+ CGI . unescape_html ( encoded_string )
15+ end
16+ end
17+ end
You can’t perform that action at this time.
0 commit comments