Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid King2014-08-29 19:18:19 +0000
committerDavid King2014-08-30 00:30:00 +0000
commit44162f71e128ec940d1c8ce79103fa8b8a6f53c6 (patch)
treeba1e39b1081d00ad73bed414d563d81448e81362 /org.eclipse.mylyn.bugzilla.core
parentbbf3291895d4a3b6afa4a61741c99968bda78728 (diff)
downloadorg.eclipse.mylyn.tasks-44162f71e128ec940d1c8ce79103fa8b8a6f53c6.tar.gz
org.eclipse.mylyn.tasks-44162f71e128ec940d1c8ce79103fa8b8a6f53c6.tar.xz
org.eclipse.mylyn.tasks-44162f71e128ec940d1c8ce79103fa8b8a6f53c6.zip
442726: Attachments with unicode characters in file names get submittedR_3_13_0e_4_4_m_3_13_x
wrongly Change-Id: Ib46683040f56fb0d524108ada844ef0d76a06907 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=442726 Signed-off-by: David King <david.king@tasktop.com>
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.core')
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaFilePart.java41
2 files changed, 42 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
index 4afccee7c..2f8c8e83d 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
@@ -55,7 +55,6 @@ import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.RedirectException;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.HeadMethod;
-import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.PartBase;
@@ -91,7 +90,6 @@ import org.eclipse.mylyn.tasks.core.RepositoryStatus;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentSource;
import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper;
-import org.eclipse.mylyn.tasks.core.data.TaskAttachmentPartSource;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
import org.eclipse.mylyn.tasks.core.data.TaskData;
@@ -999,7 +997,7 @@ public class BugzillaClient {
if (comment != null) {
parts.add(new StringPart(IBugzillaConstants.POST_INPUT_COMMENT, comment, getCharacterEncoding()));
}
- parts.add(new FilePart(IBugzillaConstants.POST_INPUT_DATA, new TaskAttachmentPartSource(source, filename)));
+ parts.add(new BugzillaFilePart(source, filename, contentType, getCharacterEncoding()));
if (isPatch) {
parts.add(new StringPart(ATTRIBUTE_ISPATCH, VALUE_ISPATCH));
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaFilePart.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaFilePart.java
new file mode 100644
index 000000000..9a0895dce
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaFilePart.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.bugzilla.core;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.commons.httpclient.methods.multipart.FilePart;
+import org.apache.commons.httpclient.util.EncodingUtil;
+import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentSource;
+import org.eclipse.mylyn.tasks.core.data.TaskAttachmentPartSource;
+
+public class BugzillaFilePart extends FilePart {
+
+ private final String filename;
+
+ public BugzillaFilePart(AbstractTaskAttachmentSource source, String filename, String contentType, String charset) {
+ super(IBugzillaConstants.POST_INPUT_DATA, new TaskAttachmentPartSource(source, null), contentType, charset);
+ this.filename = filename;
+ }
+
+ @Override
+ protected void sendDispositionHeader(OutputStream out) throws IOException {
+ super.sendDispositionHeader(out);
+ if (filename != null) {
+ out.write(EncodingUtil.getAsciiBytes(FILE_NAME));
+ out.write(QUOTE_BYTES);
+ out.write(EncodingUtil.getBytes(filename, getCharSet()));
+ out.write(QUOTE_BYTES);
+ }
+ }
+}

Back to the top