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 issue #12

Open
weathon opened this issue Jul 1, 2020 · 1 comment
Open

XSS issue #12

weathon opened this issue Jul 1, 2020 · 1 comment

Comments

@weathon
Copy link

weathon commented Jul 1, 2020

If I set my name as <script>alert()</script>, it will pop up a alert. Which is a XSS issue

@weathon
Copy link
Author

weathon commented Jul 1, 2020

I wrote a function and I think it can fix the issue

xssdangerous = ['&','/', '<', '>', "'", '"', "$","`"] 
function axss(astring)
{
    for (var i = 0; i < xssdangerous.length; i++) {//forget the g
        var regex = new RegExp(xssdangerous[i], "g");
        astring=astring.replace(regex,"&#"+xssdangerous[i].charCodeAt(0)+";")
    }
    return astring;
}

Put it into server

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