From 08445e42f0a3c2d18e1cc269e6410bf01a72d183 Mon Sep 17 00:00:00 2001 From: f1ori Date: Sat, 18 Apr 2009 15:38:29 +0000 Subject: [PATCH] * don't throw exception, in case of bad charset in http-header git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5831 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../anomic/htmlFilter/htmlFilterInputStream.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/de/anomic/htmlFilter/htmlFilterInputStream.java b/source/de/anomic/htmlFilter/htmlFilterInputStream.java index 927d91915..5f3c55439 100644 --- a/source/de/anomic/htmlFilter/htmlFilterInputStream.java +++ b/source/de/anomic/htmlFilter/htmlFilterInputStream.java @@ -51,7 +51,7 @@ public class htmlFilterInputStream extends InputStream implements htmlFilterEven private boolean charsetChanged = false; private boolean endOfHead = false; - private final Reader reader; + private Reader reader; private Writer writer; public htmlFilterInputStream( @@ -60,7 +60,7 @@ public class htmlFilterInputStream extends InputStream implements htmlFilterEven final yacyURL rooturl, final htmlFilterTransformer transformer, final boolean passbyIfBinarySuspect - ) throws UnsupportedEncodingException { + ) { // create a input stream for buffereing this.bufferedIn = new BufferedInputStream(inStream,(int) preBufferSize); this.bufferedIn.mark((int) preBufferSize); @@ -68,7 +68,16 @@ public class htmlFilterInputStream extends InputStream implements htmlFilterEven final htmlFilterContentScraper scraper = new htmlFilterContentScraper(rooturl); //scraper.registerHtmlFilterEventListener(this); - this.reader = new InputStreamReader(this,inputStreamCharset); + try { + this.reader = new InputStreamReader(this,inputStreamCharset); + } catch (UnsupportedEncodingException e) { + try { + this.reader = new InputStreamReader(this, "UTF-8"); + } catch (UnsupportedEncodingException e1) { + // how is that possible? + this.reader = new InputStreamReader(this); + } + } this.writer = new htmlFilterWriter(null,null,scraper,transformer,passbyIfBinarySuspect); }