/**
* <p> Retrieves file name from 'Content-disposition' header.
*
* @return A String with the file name for the current
* <code>encapsulation</code>.
*/
protected String getFileName()
{
String cd = getHeader("Content-disposition");
if(!cd.startsWith("form-data") && !cd.startsWith("attachment"))
return null;
int start = cd.indexOf("filename=\"");
int end = cd.indexOf('"', start+10);
- if(start == -1 || end == -1)
+ if(start == -1 || end == -1 || (start + 10) == end)
return null;
+ String str = cd.substring(start+10,end).trim();
+ if( str.length() == 0)
+ return null;
+ else
+ return str;
- return cd.substring(start+10,end);
}
>
> #1. DO NOT SEND HTML EMAIL. Please.
>
Sorry about that. I changed my Outlook Express setup to Plane Text default.
> #2. It seems that we should have more checks to make sure that we don't get
> an indexoutofboundsexception on the substring().
>
Still we need substring().trim() because of filename = " " like input.
Thanks
youngho
N�.n�+�������'�+-�x��d�{.n�+�������~X��
+�)�v�,r��y�܆m���� ��V�r�y�&�۫n)��Ib��(�H��� ��&���nW��:'�x��