[Simpleweb-Support] Upload file name issue - part 1
Brought to you by:
niallg
From: Andrew B. <and...@de...> - 2012-04-14 10:33:32
|
Have been happily using Simple for some time as an embedded HTTP server, and it has performed fantastically well. I came up against a strange issue today when trying to upload a file. Normally files don't have ' or " in them, but they are valid characters. So I have a file called Centre of 'Excellence' basic session "plan" - week 6 to 10.pdf and when I upload it all I "see" in the filename when debugging is Centre of Looking a Firebug, what is being sent up is: Content-Disposition: form-data; name="file"; filename="Centre of 'Excellence' basic session \"plan\" - week 6 to 10.pdf" and looking in the source code to DispositionParser.java it would appear it considers the ' before Excellence to be the end of the string: /** * This method is used to determine if the specified character is a quote * character. The quote character is typically used as a boundary for the * values within the header. This accepts a single or double quote. * * @param ch the character to determine if it is a quotation * * @return true if the character provided is a quotation character */ private boolean quote(char ch) { return ch == '\'' || ch == '"'; } } Is this a bug - shouldn't it be looking for a matching " that's not escaped by a back-slash? Or do some browsers send up different strings, making it impossible to have a generic algorithm? Andy Barlow - IT Consultant - MBCS CENG EURING CITP e: and...@de... t: +44 (0)7830 302 268 The information in this email or facsimile is confidential and is intended solely for the addressee(s) and access to this email or facsimile by anyone else is unauthorised. If you are not the intended recipient then any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Information expressed in this email or facsimile is not given or endorsed by my firm or employer unless otherwise indicated by an authorised representative independent of this message. |