[sword-svn] r202 - in trunk: admin src src/org/crosswire/web src/org/crosswire/web/util

scribe at crosswire.org scribe at crosswire.org
Thu Mar 31 14:09:38 MST 2005


Author: scribe
Date: 2005-03-31 14:09:37 -0700 (Thu, 31 Mar 2005)
New Revision: 202

Added:
   trunk/src/org/crosswire/web/util/
   trunk/src/org/crosswire/web/util/HTMLEncoder.java
Modified:
   trunk/admin/translate.jsp
   trunk/src/Makefile
Log:
Added new HTMLEncoder utility to help with form default strings


Modified: trunk/admin/translate.jsp
===================================================================
--- trunk/admin/translate.jsp	2005-03-31 18:59:11 UTC (rev 201)
+++ trunk/admin/translate.jsp	2005-03-31 21:09:37 UTC (rev 202)
@@ -3,6 +3,7 @@
 <%@ page import="java.io.File" %>
 <%@ page import="java.io.FileOutputStream" %>
 <%@ page import="org.crosswire.web.i18n.*" %>
+<%@ page import="org.crosswire.web.util.*" %>
 
 <html>
 <body>
@@ -52,7 +53,7 @@
 		<fieldset>
 <%
 		for (int i = 0; i < pageTags.size(); i++) {
-			String key   = (String)pageTags.get(i);
+			String key   = HTMLEncoder.encode((String)pageTags.get(i));
 			String value = TranslateTag.getTranslation(pageContext, key, false);
 %>
 			<legend><%= key %></legend>

Modified: trunk/src/Makefile
===================================================================
--- trunk/src/Makefile	2005-03-31 18:59:11 UTC (rev 201)
+++ trunk/src/Makefile	2005-03-31 21:09:37 UTC (rev 202)
@@ -3,7 +3,7 @@
 all: ../WEB-INF/classes/org/crosswire/web/i18n/TranslateTag.class
 
 ../WEB-INF/classes/org/crosswire/web/i18n/TranslateTag.class: org/crosswire/web/i18n/TranslateTag.java
-	javac -classpath ${TOMCAT_HOME}/common/lib/jsp-api.jar:${TOMCAT_HOME}/common/lib/servlet-api.jar -d ../WEB-INF/classes -sourcepath . ./org/crosswire/web/i18n/*.java
+	javac -classpath ${TOMCAT_HOME}/common/lib/jsp-api.jar:${TOMCAT_HOME}/common/lib/servlet-api.jar -d ../WEB-INF/classes -sourcepath . ./org/crosswire/web/i18n/*.java ./org/crosswire/web/util/*.java
 
 clean:
 	rm -rf ../WEB-INF/classes/org/crosswire/web/*

Added: trunk/src/org/crosswire/web/util/HTMLEncoder.java
===================================================================
--- trunk/src/org/crosswire/web/util/HTMLEncoder.java	2005-03-31 18:59:11 UTC (rev 201)
+++ trunk/src/org/crosswire/web/util/HTMLEncoder.java	2005-03-31 21:09:37 UTC (rev 202)
@@ -0,0 +1,14 @@
+package org.crosswire.web.util;
+
+public class HTMLEncoder {
+public static String encode(String in) {
+	String out = in.replaceAll("&", "&amp;");
+	out = out.replaceAll("<", "&lt;");
+	out = out.replaceAll(">", "&gt;");
+	out = out.replaceAll("\"", "&quot;");
+	out = out.replaceAll("\'", "&#039;");
+	out = out.replaceAll("\\\\", "&#092;");
+
+	return out;
+}
+}



More information about the sword-cvs mailing list