-
1. Re: [JS][regex] Question around forming a regex
John Hawkinson Apr 16, 2011 5:43 AM (in response to Roy Marshall)Err, what's that regular expression supposed to do? Perhaps you meant to use /[^\w\.@\\]/ instead of /[-\w\.@\\]/?
(Your question would also be a lot more clear if you were specific -- what's an example of a character that is treated wrongly. What were you expecting and what happened?)
Generally speaking, if you're worried about security you should explicitly include characters, not blacklist a few you think are dangerous. Because usually more are dangerous than you know.
You might also find it more useful to use encodeURIComponent(myErrorText) or maybe encodeURI(myErrorText), depending on just what it is you want to do. [What do you want to do?]
-
2. Re: [JS][regex] Question around forming a regex
Roy Marshall Apr 16, 2011 5:49 AM (in response to John Hawkinson)Thanks for the response. Will look into your comments tomorrow.
-
3. Re: [JS][regex] Question around forming a regex
Roy Marshall Apr 16, 2011 6:03 AM (in response to John Hawkinson)What I am attempting to do is capture an error message, and using a curl/AppleScript trigger a php to send me an email with the error I do have this working beautifully, but there is a strong chance that a character will be used (speech marks, spaces, non standard characters) that will error in the line of code to invoke the php script. I have manually done replaces for speech marks and spaces, but am not able to foresee all eventualities. This is my first dig into regex, so very much a training exersise for me. I hope this makes it clearer. Thanks agan Roy
-
4. Re: [JS][regex] Question around forming a regex
Roy Marshall Apr 17, 2011 1:07 PM (in response to John Hawkinson)Thanks John
Yes, the encodeURI() is exactly what I was looking to do. Thanks for the heads up!
Roy



