Ard Schrijvers pushed to branch bugfix/HSTTWO-3658 at cms-community / 
hippo-site-toolkit


Commits:
4411f8a6 by Ard Schrijvers at 2016-05-27T13:03:16+02:00
HSTTWO-3658 SearchInputParsingUtils should not allow apostrophe ’

Apply fix as suggested by Saimir (great catch!). First foldToASCIIReplacer and 
then invoke
removeInvalidAndEscapeChars, otherwise apostrophe variants are not removed but 
only '

- - - - -


2 changed files:

- content-beans/src/main/java/org/hippoecm/hst/util/SearchInputParsingUtils.java
- 
content-beans/src/test/java/org/hippoecm/hst/util/TestSearchInputParsingUtils.java


Changes:

=====================================
content-beans/src/main/java/org/hippoecm/hst/util/SearchInputParsingUtils.java
=====================================
--- 
a/content-beans/src/main/java/org/hippoecm/hst/util/SearchInputParsingUtils.java
+++ 
b/content-beans/src/main/java/org/hippoecm/hst/util/SearchInputParsingUtils.java
@@ -1,7 +1,7 @@
 package org.hippoecm.hst.util;
 
 /**
- * Copyright 2011-2015 Hippo B.V. (http://www.onehippo.com)
+ * Copyright 2011-2016 Hippo B.V. (http://www.onehippo.com)
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -63,12 +63,12 @@ public final class SearchInputParsingUtils {
         if (input == null) {
             return null;
         }
-        String parsed = compressWhitespace(input);
+        String parsed = EncodingUtils.foldToASCIIReplacer(input);
+        parsed = compressWhitespace(parsed);
         parsed = removeInvalidAndEscapeChars(parsed, 
allowSingleNonLeadingWildCardPerTerm, ignore);
         parsed = removeLeadingOrTrailingOrOperator(parsed);
         parsed = rewriteNotOperatorsToMinus(parsed);
         parsed = 
removeLeadingAndTrailingAndReplaceWithSpaceAndOperators(parsed);
-        parsed = EncodingUtils.foldToASCIIReplacer(parsed);
         log.debug("Rewrote input '{}' to '{}'", input, parsed);
         return parsed;
     }


=====================================
content-beans/src/test/java/org/hippoecm/hst/util/TestSearchInputParsingUtils.java
=====================================
--- 
a/content-beans/src/test/java/org/hippoecm/hst/util/TestSearchInputParsingUtils.java
+++ 
b/content-beans/src/test/java/org/hippoecm/hst/util/TestSearchInputParsingUtils.java
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2011-2015 Hippo B.V. (http://www.onehippo.com)
+ *  Copyright 2011-2016 Hippo B.V. (http://www.onehippo.com)
  * 
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -178,4 +178,11 @@ public class TestSearchInputParsingUtils {
         assertEquals("No 
dash",SearchInputParsingUtils.removeInvalidAndEscapeChars("No dash -", false));
         assertEquals("No 
dash",SearchInputParsingUtils.removeInvalidAndEscapeChars("No dash -", true));
     }
+
+    @Test
+    public void testSearchInputParsingUtils_parse_differentApostrophes() 
throws Exception {
+        assertEquals("The quick", SearchInputParsingUtils.parse("The quic'k", 
true));
+        assertEquals("The quick", SearchInputParsingUtils.parse("The quic’k", 
true));
+        assertEquals("The quick", SearchInputParsingUtils.parse("The quic‘k", 
true));
+    }
 }



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-site-toolkit/commit/4411f8a6b29d056aca8fc1f240aca0205f21310a
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to