Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2006-12-14 16:13:03 -0500
committerrelves2006-12-14 16:13:03 -0500
commit3ad7521837542be183fe776644511d24b9856cfe (patch)
tree593d8efd5ea883861985414e10399ac260645c72
parentc122a32b4c83e91622582c5b5d7d71726b4f8864 (diff)
downloadorg.eclipse.mylyn.tasks-3ad7521837542be183fe776644511d24b9856cfe.tar.gz
org.eclipse.mylyn.tasks-3ad7521837542be183fe776644511d24b9856cfe.tar.xz
org.eclipse.mylyn.tasks-3ad7521837542be183fe776644511d24b9856cfe.zip
ASSIGNED - bug 161488: Bugzilla - Invalid XML
https://bugs.eclipse.org/bugs/show_bug.cgi?id=161488
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/AbstractReportFactory.java58
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/web/WebClientUtil.java2
2 files changed, 52 insertions, 8 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/AbstractReportFactory.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/AbstractReportFactory.java
index a1ad3c62a..1fe4f3e02 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/AbstractReportFactory.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/AbstractReportFactory.java
@@ -11,10 +11,13 @@
package org.eclipse.mylar.internal.bugzilla.core;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.io.StringReader;
import java.security.GeneralSecurityException;
@@ -53,15 +56,22 @@ public class AbstractReportFactory {
protected void collectResults(DefaultHandler contentHandler, boolean clean) throws IOException, BugzillaException,
GeneralSecurityException {
- if(inStream == null) {
+ if (inStream == null) {
return;
}
-
+
+ ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+
+ copyAndCleanByteStream(inStream, byteStream);
+
BufferedReader in;
if (characterEncoding != null) {
- in = new BufferedReader(new InputStreamReader(inStream, characterEncoding));
+ // in = new BufferedReader(new InputStreamReader(inStream,
+ // characterEncoding));
+ in = new BufferedReader(new StringReader(byteStream.toString(characterEncoding)));
} else {
- in = new BufferedReader(new InputStreamReader(inStream));
+ // in = new BufferedReader(new InputStreamReader(inStream));
+ in = new BufferedReader(new StringReader(byteStream.toString()));
}
if (in != null && clean) {
@@ -78,8 +88,7 @@ public class AbstractReportFactory {
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
// The default resolver will try to resolve the dtd via
- // URLConnection. We would need to implement
- // via httpclient to handle authorization properly. Since we
+ // URLConnection. Since we
// don't have need of entity resolving
// currently, we just supply a dummy (empty) resource for
// each request...
@@ -113,4 +122,39 @@ public class AbstractReportFactory {
}
}
}
+
+ private void copyAndCleanByteStream(InputStream in, OutputStream out) throws IOException {
+
+ if (in != null && out != null) {
+ BufferedInputStream inBuffered = new BufferedInputStream(in);
+
+ int bufferSize = 1000;
+ byte[] buffer = new byte[bufferSize];
+
+ int readCount;
+
+ BufferedOutputStream outStream = new BufferedOutputStream(out);
+
+ while ((readCount = inBuffered.read(buffer)) != -1) {
+ for (int x = 0; x < readCount; x++) {
+
+ if (!Character.isISOControl(buffer[x])) {
+ outStream.write(buffer[x]);
+ } else if (buffer[x] == '\n' || buffer[x] == '\r') {
+ outStream.write(buffer[x]);
+ }
+ }
+ // if (readCount < bufferSize) {
+ // outStream.write(buffer, 0, readCount);
+ // } else {
+ // outStream.write(buffer);
+ // }
+ }
+ outStream.flush();
+ outStream.close();
+ in.close();
+ }
+
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/web/WebClientUtil.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/web/WebClientUtil.java
index be9f6d30e..f51f52803 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/web/WebClientUtil.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/web/WebClientUtil.java
@@ -36,7 +36,7 @@ public class WebClientUtil {
// private static final int COM_TIME_OUT = 30000;
- public static final String ENCODING_GZIP = "gzip";
+ //public static final String ENCODING_GZIP = "gzip";
public static void initCommonsLoggingSettings() {
// TODO: move?

Back to the top