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

TypeError: Cannot read property 'replace' of undefined #192

Open
jorgefo opened this issue Jun 4, 2016 · 1 comment
Open

TypeError: Cannot read property 'replace' of undefined #192

jorgefo opened this issue Jun 4, 2016 · 1 comment

Comments

@jorgefo
Copy link

jorgefo commented Jun 4, 2016

I have this error

TypeError: Cannot read property 'replace' of undefined
at S.escapeHTML (C:\Nodejs\node_modules\string\lib\string.js:174:41)

this happend when i try this option
S(req.query.ja).escapeHTML();

The value of req.query.ja is null

escapeHTML: function() { //from underscore.string return new this.constructor(this.s.replace(/[&<>"']/g, function(m){ return '&' + reversedEscapeChars[m] + ';'; })); },

I solved the problem with add this line

if (this.s == null) return '';

escapeHTML: function() { //from underscore.string if (this.s == null) return ''; return new this.constructor(this.s.replace(/[&<>"']/g, function(m){ return '&' + reversedEscapeChars[m] + ';'; })); }

This is my first post in Github sorry if this is not normal way to report this issue XD

@ewrogers
Copy link

ewrogers commented Jun 6, 2016

Good find, fixed in PR #193 . Hopefully can be merged into master soon.

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

2 participants