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

XSS protection for Twitter_Form_Decorator_Errors #34

Open
dbistriceanu opened this issue Jul 14, 2014 · 0 comments
Open

XSS protection for Twitter_Form_Decorator_Errors #34

dbistriceanu opened this issue Jul 14, 2014 · 0 comments

Comments

@dbistriceanu
Copy link

Because error messages usually contain user input, it would be safer to properly sanitize them to prevent possible XSS attacks, as the error messages are outputted directly as HTML in your Twitter_Form_Decorator_Errors:

...
$errorHtml = "";
foreach($errors as $currentError)
{
    $errorHtml .= '<span class="help-block">'.$currentError.'</span>';
}
...

One possible way to do this would be by replacing

$errorHtml .= '<span class="help-block">'.$currentError.'</span>';

with

$errorHtml .= '<span class="help-block">' . htmlentities($currentError) . '</span>';

This will convert all applicable characters from the error messages to their corresponding HTML entities, and as such offer the desired XSS protection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant