Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok, I found the cause of the problem. </p> <p>On the search-view, the string to be searched for is cleaned with:</p> <pre><code> $q = Sanitize::clean($this-&gt;request-&gt;params['named']['q']); </code></pre> <p>Which among other things runs html_entities on the string as default, when <code>'encode' =&gt; true</code> is set (default). This would turn e.g. <code>ö</code> into <code>&amp;ouml;</code> and then search for words with html-entities on them. </p> <p>I got a workaround by doing:</p> <pre><code> $q = $this-&gt;request-&gt;params['named']['q']; // Use encode=false on Sanitize::clean to prevent äüöß etc. getting // replaced by html entities. And strip tags manually first to prevent // html injected strings. $q = strip_tags($q); $q = Sanitize::clean($q, array('encode' =&gt; false)); </code></pre> <p><strong>Note</strong>: If like in my case, TinyMCE is set with <code>'entity_encoding' =&gt; 'raw'</code> then the body field in the nodes table would contain äöü instead of htmlentities as well, which IMO is a far better practice as replacing them with htmlentities. Per default though, tinymce replaces chars with htmlentities, so the body field would work with the default search behaviour of Croogo/Cakephp. But searching, for example, in the title-field wouldn't.</p> <p><strong>Update</strong></p> <p>Ok, as mark comments suggested, sanitizing and using cake's paginate method, is not necessary, so the Sanitize part can be skipped. I also found using htmlspecialchars even better as strip_tags, as strip_tags wouldn't take care of e.g. '&amp;', and on the body, tinyMCE saves those as html_entities. So the updated code would look like this:</p> <pre><code> $q = htmlspecialchars($this-&gt;request-&gt;params['named']['q']); // go on with searching for nodes on paginate-method </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload