From: <bra...@us...> - 2008-02-02 00:57:44
|
Revision: 2171 http://archive-access.svn.sourceforge.net/archive-access/?rev=2171&view=rev Author: bradtofel Date: 2008-02-01 16:57:46 -0800 (Fri, 01 Feb 2008) Log Message: ----------- BUGFIX: was not catching IllegalCharsetName exception.. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/replay/HTMLPage.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/replay/HTMLPage.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/replay/HTMLPage.java 2008-02-01 23:53:57 UTC (rev 2170) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/replay/HTMLPage.java 2008-02-02 00:57:46 UTC (rev 2171) @@ -29,6 +29,7 @@ import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; +import java.nio.charset.IllegalCharsetNameException; import java.text.ParseException; import java.util.Map; @@ -88,11 +89,21 @@ this.uriConverter = uriConverter; } + private boolean isCharsetSupported(String charsetName) { + // can you believe that this throws a runtime? Just asking if it's + // supported!!?! They coulda just said "no"... + try { + return Charset.isSupported(charsetName); + } catch(IllegalCharsetNameException e) { + return false; + } + } + private String contentTypeToCharset(final String contentType) { int offset = contentType.indexOf(CHARSET_TOKEN); if (offset != -1) { String cs = contentType.substring(offset + CHARSET_TOKEN.length()); - if(Charset.isSupported(cs)) { + if(isCharsetSupported(cs)) { return cs; } // test for extra spaces... there's at least one page out there that @@ -101,7 +112,7 @@ // <meta http-equiv="Content-type" content="text/html; charset=i so-8859-1"> // bad web page! - if(Charset.isSupported(cs.replace(" ", ""))) { + if(isCharsetSupported(cs.replace(" ", ""))) { return cs.replace(" ", ""); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |