Author: max.andersen(a)jboss.com
Date: 2008-11-26 07:21:24 -0500 (Wed, 26 Nov 2008)
New Revision: 15620
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/HibernateConfigurationExporter.java
Log:
JBIDE-3198 escape <> in properties of cfg.xml (by Dima)
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/HibernateConfigurationExporter.java
===================================================================
---
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/HibernateConfigurationExporter.java 2008-11-26
11:28:20 UTC (rev 15619)
+++
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/HibernateConfigurationExporter.java 2008-11-26
12:21:24 UTC (rev 15620)
@@ -109,7 +109,7 @@
}
}
if(key.startsWith("hibernate.") ) { // if not starting with
hibernate. not relevant for cfg.xml
- pw.println(" <property name=\"" + key +
"\">" + element.getValue() + "</property>");
+ pw.println(" <property name=\"" + key +
"\">" + forXML(element.getValue().toString()) +
"</property>");
}
}
@@ -170,4 +170,27 @@
public String getName() {
return "cfg2cfgxml";
}
+
+ /**
+ *
+ * @param text
+ * @return String with escaped [<,>] special characters.
+ */
+ public static String forXML(String text) {
+ if (text == null) return null;
+ final StringBuilder result = new StringBuilder();
+ char[] chars = text.toCharArray();
+ for (int i = 0; i < chars.length; i++){
+ char character = chars[i];
+ if (character == '<') {
+ result.append("<");
+ } else if (character == '>'){
+ result.append(">");
+ } else {
+ result.append(character);
+ }
+ }
+ return result.toString();
+ }
+
}
Show replies by date