Fixed heavy-handed early escaping of @query, and ensured all usages of it (HTML header text, HTML form field value, DB query, & JSON output) are being properly escaped.
Removed Rack::Utils.escape_html(…) from Web's before do.
Added a html_escape to views/search.haml— I'm not sure why it wasn't being escaped automatically (I don't see a .raw call or similar anywhere), but this properly escapes HTML stuff.
‣ Tested with the search string <br/> and it properly displayed a title of 0 Results for '<br/>'.
Verified that the %input{type: 'search', name: 'q', … in views/layout.haml is properly escaping its field value.
‣ Tested with the search string "><br/> and it properly delivered HTML <input … name="q" … value=""><br/>" …>.
Verified that the Session.db[…] call in Session.search is properly escaping query.
‣ Read over the docs regarding how DB.literal works and tried SQL injection strings.
Verified that JSON search output is properly escaping the query.
‣ Tested with the search string '"} and it properly delivered JSON {"query":"'\"}","results":[]}.
Fixed heavy-handed early escaping of
@query
, and ensured all usages of it (HTML header text, HTML form field value, DB query, & JSON output) are being properly escaped.Rack::Utils.escape_html(…)
fromWeb
'sbefore do
.html_escape
toviews/search.haml
— I'm not sure why it wasn't being escaped automatically (I don't see a.raw
call or similar anywhere), but this properly escapes HTML stuff.‣ Tested with the search string
<br/>
and it properly displayed a title of0 Results for '<br/>'
.%input{type: 'search', name: 'q', …
inviews/layout.haml
is properly escaping its field value.‣ Tested with the search string
"><br/>
and it properly delivered HTML<input … name="q" … value=""><br/>" …>
.Session.db[…]
call inSession.search
is properly escapingquery
.‣ Read over the docs regarding how
DB.literal
works and tried SQL injection strings.‣ Tested with the search string
'"}
and it properly delivered JSON{"query":"'\"}","results":[]}
.Fixes ASCIIwwdc/asciiwwdc.com#29