kinman 2002/10/11 18:08:32
Modified: jasper2/src/share/org/apache/jasper/compiler Tag:
tomcat_4_branch Generator.java
Log:
- Fix 13536: bad <jsp:param> value in plugin if the value is an expression.
Revision Changes Path
No revision
No revision
1.35.2.10 +34 -14
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java
Index: Generator.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
retrieving revision 1.35.2.9
retrieving revision 1.35.2.10
diff -u -r1.35.2.9 -r1.35.2.10
--- Generator.java 3 Oct 2002 19:25:18 -0000 1.35.2.9
+++ Generator.java 12 Oct 2002 01:08:31 -0000 1.35.2.10
@@ -107,8 +107,19 @@
if (s == null)
return "null";
+ return '"' + escape( s ) + '"';
+ }
+
+ /**
+ * @param s the input string
+ * @return escaped string, per Java rule
+ */
+ private static String escape(String s) {
+
+ if (s == null)
+ return "";
+
StringBuffer b = new StringBuffer();
- b.append('"');
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '"')
@@ -122,7 +133,6 @@
else
b.append(c);
}
- b.append('"');
return b.toString();
}
@@ -889,15 +899,25 @@
else if (name.equalsIgnoreCase ("type"))
name = "java_type";
- String s0 = makeAttr("name", name) + " value=" +
- attributeValue(n.getValue(), false);
-
- if (ie) {
- s0 = "<PARAM" + s0 + '>';
- }
-
- n.setBeginJavaLine(out.getJavaLine());
- out.printil("out.println(" + quote(s0) + ");");
+ n.setBeginJavaLine(out.getJavaLine());
+ if( ie ) {
+ // We want something of the form
+ // out.println( "<PARAM name=\"blah\"
+ // value=\"" + ... + "\">" );
+ out.printil( "out.write( \"<PARAM name=\\\"" +
+ escape( name ) + "\\\" value=\\\"\" + " +
+ attributeValue( n.getValue(), false) +
+ " + \"\\\">\" );" );
+ out.printil("out.write(\"\\n\");");
+ }
+ else {
+ // We want something of the form
+ // out.print( " blah=\"" + ... + "\"" );
+ out.printil( "out.write( \" " + escape( name ) +
+ "=\\\"\" + " +
+ attributeValue( n.getValue(), false) +
+ " + \"\\\"\" );" );
+ }
n.setEndJavaLine(out.getJavaLine());
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>