- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Sun, 15 Feb 2009 18:23:26 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/parser In directory hutz:/tmp/cvs-serv17380/org/w3c/css/parser Modified Files: CssFouffa.java Log Message: fix for charset support of fake URIs (upload and text input) Index: CssFouffa.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssFouffa.java,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- CssFouffa.java 14 Feb 2009 09:05:03 -0000 1.48 +++ CssFouffa.java 15 Feb 2009 18:23:24 -0000 1.49 @@ -20,6 +20,8 @@ import java.util.Enumeration; import java.util.Vector; +import java.nio.charset.Charset; + import org.w3c.css.css.StyleSheetOrigin; import org.w3c.css.parser.analyzer.CssParser; import org.w3c.css.parser.analyzer.CssParserTokenManager; @@ -330,10 +332,21 @@ * if an I/O error occurs. */ public void ReInit(ApplContext ac, URL file) throws IOException { - Frame f = new Frame(this, file.toString(), ac.getWarningLevel()); + InputStream is; + URL url; + Frame f; + + f = new Frame(this, file.toString(), ac.getWarningLevel()); ac.setFrame(f); - URLConnection urlC = HTTPURL.getConnection(file, ac); - ReInit(ac, HTTPURL.getInputStream(ac, urlC), urlC.getURL(), f); + if (ac.isInputFake()) { + is = ac.getFakeInputStream(); + url = file; + } else { + URLConnection urlC = HTTPURL.getConnection(file, ac); + is = HTTPURL.getInputStream(ac, urlC); + url = urlC.getURL(); + } + ReInit(ac, is, url, f); } /** @@ -679,20 +692,24 @@ e.hasMoreElements();) { e.nextElement().addCharSet(charset); } - String originalCharset = ac.getCharsetForURL(getURL()); - if (!charset.equalsIgnoreCase(originalCharset)) { - if (originalCharset == null) { - ac.setCharsetForURL(getURL(), charset); - try { - ReInit(ac, getURL()); - } catch (IOException ioex) {} - } else { - Exception ex = new Exception("Conflicting charset definition"+ - "between network and @charset "+ - originalCharset+" and "+charset); - CssError cerr = new CssError(ex); - ac.getFrame().addError(cerr); - } + Charset c = null; + try { + c = Charset.forName(charset); + } catch (Exception ex) { + return; + } + Charset originalCharset = ac.getCharsetObjForURL(getURL()); + if (originalCharset == null) { + ac.setCharsetForURL(getURL(), c); + try { + ReInit(ac, getURL()); + } catch (IOException ioex) {} + } else if (c.compareTo(originalCharset) != 0) { + Exception ex = new Exception("Conflicting charset definition "+ + "between network and @charset "+ + originalCharset+" and "+charset); + CssError cerr = new CssError(ex); + ac.getFrame().addError(cerr); } }
Received on Sunday, 15 February 2009 18:32:01 UTC