- From: Sijtsche Smeman <sijtsche@dev.w3.org>
- Date: Thu, 25 Nov 2004 13:28:43 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/css In directory hutz:/tmp/cvs-serv10932/css Modified Files: CssRuleList.java Log Message: output escaped to prevent malicious HTML or script to be executed Index: CssRuleList.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/css/CssRuleList.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- CssRuleList.java 30 May 2004 05:06:51 -0000 1.7 +++ CssRuleList.java 25 Nov 2004 13:28:41 -0000 1.8 @@ -5,10 +5,12 @@ package org.w3c.css.css; -import org.w3c.css.parser.AtRule; import java.util.Vector; import java.io.PrintWriter; +import org.w3c.css.parser.AtRule; +import org.w3c.css.util.Util; + public class CssRuleList { AtRule atRule; @@ -18,112 +20,112 @@ String indent; public CssRuleList() { - atRule = null; - atRuleString = new String(); - rulelist = new Vector(); - String pseudopage = new String(); - indent = new String(); + atRule = null; + atRuleString = new String(); + rulelist = new Vector(); + String pseudopage = new String(); + indent = new String(); } public void addStyleRule(CssStyleRule stylerule) { - rulelist.addElement(stylerule); + rulelist.addElement(stylerule); } public Vector getStyleRules() { - return rulelist; + return rulelist; } public void addAtRule(AtRule atRule) { - this.atRule = atRule; - atRuleString = atRule.toString(); + this.atRule = atRule; + atRuleString = atRule.toString(); } public String getAtRule() { - return atRuleString; + return atRuleString; } public String toString() { - StringBuffer ret = new StringBuffer(); - - if (atRule.isEmpty()) { - if (null != atRule && !atRuleString.equals("")) { - ret.append(atRuleString); - ret.append(' '); - ret.append('\n'); - } - } else { - if (!atRuleString.equals("")) { - ret.append(atRuleString); - ret.append(' '); - ret.append('{'); - ret.append('\n'); - indent = " "; - } - for (int i = 0; i < rulelist.size() ; i++ ) { - ret.append(indent); - ret.append(((CssStyleRule)rulelist.elementAt(i)).toString()); - } + StringBuffer ret = new StringBuffer(); + + if (atRule.isEmpty()) { + if (null != atRule && !atRuleString.equals("")) { + ret.append(atRuleString); + ret.append(' '); + ret.append('\n'); + } + } else { + if (!atRuleString.equals("")) { + ret.append(atRuleString); + ret.append(' '); + ret.append('{'); + ret.append('\n'); + indent = " "; + } + for (int i = 0; i < rulelist.size() ; i++ ) { + ret.append(indent); + ret.append(((CssStyleRule)rulelist.elementAt(i)).toString()); + } - if (!atRuleString.equals("")) { - ret.append('}'); - ret.append('\n'); - } - } - return ret.toString(); + if (!atRuleString.equals("")) { + ret.append('}'); + ret.append('\n'); + } + } + return ret.toString(); } /* public String toHTML() { - StringBuffer ret = new StringBuffer(); + StringBuffer ret = new StringBuffer(); - if (null != atRule && atRule.isEmpty()) { - if (!atRuleString.equals("")) { - ret.append("<li><span class='atSelector'>"); - ret.append(atRuleString); - ret.append("</span></li> \n\n"); - } - } else { - if (!atRuleString.equals("")) { - ret.append("<li><span class='atSelector'>"); - ret.append(atRuleString); - ret.append("</span> {\n<ul>\n"); - } - for (int i = 0; i < rulelist.size() ; i++ ) { - ret.append(((CssStyleRule)rulelist.elementAt(i)).toHTML()); - } + if (null != atRule && atRule.isEmpty()) { + if (!atRuleString.equals("")) { + ret.append("<li><span class='atSelector'>"); + ret.append(atRuleString); + ret.append("</span></li> \n\n"); + } + } else { + if (!atRuleString.equals("")) { + ret.append("<li><span class='atSelector'>"); + ret.append(atRuleString); + ret.append("</span> {\n<ul>\n"); + } + for (int i = 0; i < rulelist.size() ; i++ ) { + ret.append(((CssStyleRule)rulelist.elementAt(i)).toHTML()); + } - if (!atRuleString.equals("")) { - ret.append("</ul>}</li>\n"); - } - } - return ret.toString(); + if (!atRuleString.equals("")) { + ret.append("</ul>}</li>\n"); + } + } + return ret.toString(); } */ public void toHTML(PrintWriter out) { - if (null != atRule && atRule.isEmpty()) { - if (!atRuleString.equals("")) { - out.print("<li><span class='atSelector'>"); - out.print(atRuleString); - out.print("</span></li> \n\n"); - } - } else { - if (!atRuleString.equals("")) { - out.print("<li><span class='atSelector'>"); - out.print(atRuleString); - out.print("</span> {\n<ul>\n"); - } - for (int i = 0; i < rulelist.size() ; i++ ) { - ((CssStyleRule)rulelist.elementAt(i)).toHTML(out); - } - - if (!atRuleString.equals("")) { - out.print("</ul>}</li>\n"); - } - } + if (null != atRule && atRule.isEmpty()) { + if (!atRuleString.equals("")) { + out.print("<li><span class='atSelector'>"); + out.print(Util.escapeHTML(atRuleString)); + out.print("</span></li> \n\n"); + } + } else { + if (!atRuleString.equals("")) { + out.print("<li><span class='atSelector'>"); + out.print(Util.escapeHTML(atRuleString)); + out.print("</span> {\n<ul>\n"); + } + for (int i = 0; i < rulelist.size() ; i++ ) { + ((CssStyleRule)rulelist.elementAt(i)).toHTML(out); + } + + if (!atRuleString.equals("")) { + out.print("</ul>}</li>\n"); + } + } } public void clear() { - atRuleString = ""; - rulelist.removeAllElements(); - pseudopage = ""; + atRuleString = ""; + rulelist.removeAllElements(); + pseudopage = ""; } }
Received on Thursday, 25 November 2004 13:28:44 UTC