I'm trying to parse a multipart/form-data request properly, it works unless the file that is beeing uploaded contains double quotes.
The request looks like (excerpt from wireshark):
Content-Disposition: form-data; name="file"; filename="b'e\"e.JPG"
So the file is actually called b'e"e.jpg on my local filesystem. The browser escapes the quotes properly.
I want to grab the filename b'e\"e.JPG
out of this string.
I found a regex for grabbing quoted strings with escaped quotes inside:
/"[^"\\]*(\\.[^"\\]*)*"/i
(source http://www.regular-expressions.info/regexbuddy/stringescapedmulti.html)
The regex works perfectly when applied on the string "b'e\"e.JPG"
but when I try to scope it only on the filename=
part, like:
/filename="[^"\\]*(\\.[^"\\]*)*"/i
I won't get any results.
Any help would be really appreciated
Edit:
I'm working with JavaScript, so I put the regex on js fiddle: http://jsfiddle.net/hDBcs/
Thanks!
Simon
Possibly the problem is that you are not using brackets in order to get needed parts:
/filename="([^"\\]*(?:\\.[^"\\]*)*)"/i
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With