Improve handling of attachments names with quotes

Partially resolves #2272
This commit is contained in:
Francis Lachapelle
2016-06-01 09:18:22 -04:00
parent e5bebf87a8
commit d9d8ed37f9
3 changed files with 6 additions and 7 deletions
+2 -2
View File
@@ -1304,7 +1304,7 @@ static NSString *userAgent = nil;
{
s = [self mimeTypeForExtension:[_name pathExtension]];
if ([_name length] > 0)
s = [s stringByAppendingFormat: @"; name=\"%@\"", _name];
s = [s stringByAppendingFormat: @"; name=\"%@\"", [_name stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]];
}
return s;
@@ -1330,7 +1330,7 @@ static NSString *userAgent = nil;
cdtype = @"attachment";
cd = [cdtype stringByAppendingString: @"; filename=\""];
cd = [cd stringByAppendingString: _name];
cd = [cd stringByAppendingString: [_name stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]];
cd = [cd stringByAppendingString: @"\""];
// TODO: add size parameter (useful addition, RFC 2183)
+3 -4
View File
@@ -526,10 +526,9 @@ static NSArray *infoKeys = nil;
if (!attachedFiles)
attachedFiles = [NSMutableArray new];
newFilename = filename;
baseFilename = [filename stringByDeletingPathExtension];
extension = [filename pathExtension];
newFilename = [filename stringByReplacingOccurrencesOfString:@"\\\"" withString:@"\""]; /* to real filename */
baseFilename = [newFilename stringByDeletingPathExtension];
extension = [newFilename pathExtension];
variation = 0;
while ([attachedFiles containsObject: newFilename])
{
+1 -1
View File
@@ -118,7 +118,7 @@
<li class="attachButton"><span class="button fileinput-button"><span><img rsrc:src="title_attachment_14x14.png" /> <var:string label:value="Attach"/></span><input id="fileUpload" type="file" name="attachments" tabindex="-1" multiple="multiple"/></span></li>
<var:foreach list="attachmentAttrs" item="attachment"
><li class="progressDone" var:data-filename="attachment.filename">
<i class="icon-attachment"><!-- icon --></i><a var:href="attachment.url" target="_new"><var:string value="attachment.filename"/></a><span class="muted">(<var:string value="attachment.size" formatter="sizeFormatter" />)</span>
<i class="icon-attachment"><!-- icon --></i><a var:href="attachment.url" target="_new"><var:string value="attachment.filename" const:escapeHTML="YES"/></a><span class="muted">(<var:string value="attachment.size" formatter="sizeFormatter"/>)</span>
</li></var:foreach>
</ul>
</div>