Author: ssmiweve
Date: 2008-01-31 13:51:26 +0100 (Thu, 31 Jan 2008)
New Revision: 6071

Modified:
   
branches/2.16/data-model-api/src/main/java/no/sesat/search/datamodel/generic/StringDataObjectSupport.java
   
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/ChopStringDirective.java
   
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/HtmlEscapeDirective.java
   
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/RemovePrefixDirective.java
   
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/XmlEscapeDirective.java
Log:
SEARCH-4057 - New tool for string escaping
 always use escapeXml instead of escapeHtml.
 but replace ' with '


Modified: 
branches/2.16/data-model-api/src/main/java/no/sesat/search/datamodel/generic/StringDataObjectSupport.java
===================================================================
--- 
branches/2.16/data-model-api/src/main/java/no/sesat/search/datamodel/generic/StringDataObjectSupport.java
   2008-01-30 14:23:29 UTC (rev 6070)
+++ 
branches/2.16/data-model-api/src/main/java/no/sesat/search/datamodel/generic/StringDataObjectSupport.java
   2008-01-31 12:51:26 UTC (rev 6071)
@@ -23,13 +23,9 @@
 
 package no.sesat.search.datamodel.generic;
 
-import no.sesat.search.datamodel.generic.DataObject;
-import no.sesat.search.datamodel.*;
-import no.sesat.search.datamodel.generic.StringDataObject;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 
 /**
@@ -87,7 +83,9 @@
     
     public String getXmlEscaped(){
         
-        return null != getString() ? StringEscapeUtils.escapeXml(getString()) 
: null;
+        return null != getString() 
+                ? 
StringEscapeUtils.escapeXml(getString()).replaceAll("'", "'") // see 
SEARCH-4057
+                : null;
     }
     
     

Modified: 
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/ChopStringDirective.java
===================================================================
--- 
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/ChopStringDirective.java
        2008-01-30 14:23:29 UTC (rev 6070)
+++ 
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/ChopStringDirective.java
        2008-01-31 12:51:26 UTC (rev 6071)
@@ -96,7 +96,7 @@
             final boolean chopWord = argCount > 3 && 
Boolean.parseBoolean(getArgument(context, node, 3));
             
             final String chopSuey = esc
-                    ? StringEscapeUtils.escapeHtml(StringChopper.chop(s, 
length, chopWord))
+                    ? StringEscapeUtils.escapeXml(StringChopper.chop(s, 
length, chopWord))
                     : StringChopper.chop(s, length, chopWord);
             
             writer.write(chopSuey);

Modified: 
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/HtmlEscapeDirective.java
===================================================================
--- 
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/HtmlEscapeDirective.java
        2008-01-30 14:23:29 UTC (rev 6070)
+++ 
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/HtmlEscapeDirective.java
        2008-01-31 12:51:26 UTC (rev 6071)
@@ -43,6 +43,8 @@
  * </code>
  *
  * @author magnuse
+ * @version $Id$
+ * @deprecated use XmlEscapeDirective instead as we render xhtml pages.
  */
 public final class HtmlEscapeDirective extends Directive {
 

Modified: 
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/RemovePrefixDirective.java
===================================================================
--- 
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/RemovePrefixDirective.java
      2008-01-30 14:23:29 UTC (rev 6070)
+++ 
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/RemovePrefixDirective.java
      2008-01-31 12:51:26 UTC (rev 6071)
@@ -1,19 +1,19 @@
 /*
  * Copyright (2005-22007 Schibsted Søk AS
- *   This file is part of SESAT.
- *
- *   SESAT is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU Affero General Public License as published 
by
- *   the Free Software Foundation, either version 3 of the License, or
- *   (at your option) any later version.
- *
- *   SESAT is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU Affero General Public License for more details.
- *
- *   You should have received a copy of the GNU Affero General Public License
- *   along with SESAT.  If not, see <http://www.gnu.org/licenses/>.
+ *   This file is part of SESAT.
+ *
+ *   SESAT is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU Affero General Public License as published 
by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   SESAT is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU Affero General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Affero General Public License
+ *   along with SESAT.  If not, see <http://www.gnu.org/licenses/>.
  */
 package no.sesat.search.view.velocity;
 
@@ -89,8 +89,9 @@
             returnString = returnString.trim();
         }
 
-        if ("html".equalsIgnoreCase(encoding)) {
-            writer.write(StringEscapeUtils.escapeHtml(returnString));
+        if ("html".equalsIgnoreCase(encoding) || 
"xml".equalsIgnoreCase(encoding)) {
+            // sesat prefers xhtml
+            writer.write(StringEscapeUtils.escapeXml(returnString));
         } else {
             writer.write(URLEncoder.encode(returnString, encoding));
         }

Modified: 
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/XmlEscapeDirective.java
===================================================================
--- 
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/XmlEscapeDirective.java
 2008-01-30 14:23:29 UTC (rev 6070)
+++ 
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/XmlEscapeDirective.java
 2008-01-31 12:51:26 UTC (rev 6071)
@@ -37,6 +37,7 @@
 /**
  *
  * @author maek
+ * @version $Id$
  */
 public class XmlEscapeDirective extends Directive {
 

_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits

Reply via email to