Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Error message isn't HTML escaped #1810

Closed
saltycrys opened this issue Feb 25, 2021 · 3 comments · Fixed by #2874
Closed

[Bug] Error message isn't HTML escaped #1810

saltycrys opened this issue Feb 25, 2021 · 3 comments · Fixed by #2874
Labels
bug Something isn't working good first issue Good for newcomers type:server-side

Comments

@saltycrys
Copy link
Member

saltycrys commented Feb 25, 2021

The error message isn't HTML escaped, leading to messages like #1755.

Route: /feed/trending?type=News®ion=US

should be

Route: /feed/trending?type=News&region=US


The error message is created here:

def error_template_helper(env : HTTP::Server::Context, locale : Hash(String, JSON::Any) | Nil, status_code : Int32, exception : Exception)
if exception.is_a?(InfoException)
return error_template_helper(env, locale, status_code, exception.message || "")
end
env.response.content_type = "text/html"
env.response.status_code = status_code
issue_template = %(Title: `#{exception.message} (#{exception.class})`)
issue_template += %(\nDate: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`)
issue_template += %(\nRoute: `#{env.request.resource}`)
issue_template += %(\nVersion: `#{SOFTWARE["version"]} @ #{SOFTWARE["branch"]}`)
# issue_template += github_details("Preferences", env.get("preferences").as(Preferences).to_pretty_json)
issue_template += github_details("Backtrace", exception.inspect_with_backtrace)
error_message = <<-END_HTML
Looks like you've found a bug in Invidious. Please open a new issue
<a href="https://github.com/iv-org/invidious/issues">on GitHub</a>
and include the following text in your message:
<pre style="padding: 20px; background: rgba(0, 0, 0, 0.12345);">#{issue_template}</pre>
END_HTML
return templated "error"
end

See https://crystal-lang.org/api/0.35.1/HTML.html#escape(string:String):String-class-method

@saltycrys saltycrys added bug Something isn't working good first issue Good for newcomers labels Feb 25, 2021
@hackerncoder
Copy link
Contributor

Don't you mean #1755

@saltycrys
Copy link
Member Author

Don't you mean #1755

Yes, thank you.

@hackerncoder
Copy link
Contributor

#1838 Is another one that shows this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers type:server-side
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants