Rack::Utils.escape_html(string) does not work as described in the teacher's notes
When adding the following to my wiki.rb file:
def escape(string) Rack::Utils.escape_html(string) end
And adding the following in my show.erb file:
<p><%= escape @content %></p>
When adding the following content when creating a new page:
My results were the following:
Shouldn't this have rendered as
<script>alert('boo');</script>, but with the HTML entities escaped?
Jay McGavrenTreehouse Teacher
Hmm, that's true! Another method (that's meant for escaping special characters in URLs) is overriding the
Looks like the fix is just to re-name the method we add to wiki.rb. I went with a method name of
h (as in "HTML"):
def h(string) Rack::Utils.escape_html(string) end
I've updated the teacher's notes to reflect this. Sorry for the confusion!