Hi Andy! Thanks for your hints.

As you said, multibyte characters were filtered out by the
Sanitize::paranoid method.
So I replaced it with my own sanitize method.

I don't know if it's a good way or not, but it works properly.


        function in_one($match = null) {
                //uses('Sanitize');
                if (isset($this->data['Form']['search'])) {
                        if (!$this->data['Form']['search']) {
                                $this->_addFlash('You need to search for 
something');
                        }
                        //return $this->redirect 
(array(Sanitize::paranoid($this-
>data['Form']['search'])));
                        return $this->redirect 
(array($this->mb_paranoid($this->data['Form']
['search'])));
                }
                if ($match) {
                        //$match = Sanitize::paranoid($match);
                        $match = $this->mb_paranoid($match);

                        $this->_addFlash('Showing results for Titles matching 
"'.
$match.'"');

                        $criteria = array('Title.title'=>"LIKE %$match%");
                        list($order,$limit,$page) = $this->Pagination-
>init($criteria,null,array('ajaxAutoDetect'=>false));
                        $this->data = 
$this->{$this->modelClass}->findAll($criteria, null,
$order, $limit, $page);
                        $this->data['Form']['search'] = $match;
                } else {
                        $this->data = null;
                }
                $this->render('in_one');
        }

        function mb_paranoid($string, $allowed = array()) {
                $allow = null;
                if (!empty($allowed)) {
                        foreach($allowed as $value) {
                                $allow .= "\\$value";
                        }
                }

                if (is_array($string)) {
                        foreach($string as $key => $clean) {
                                $cleaned[$key] = $this->mb_preg_replace($clean, 
$allow);
                        }
                } else {
                        $cleaned = $this->mb_preg_replace($string, $allow);
                }
                return $cleaned;
        }


        function mb_preg_replace($string, $allow) {
                        // Allows UTF-8 characters
                        $cleaned = preg_replace(
                        
"/[^{$allow}\\x00-\\x7F\\xC0-\\xDF\\x80-\\xBF\\xE0-\\xEF\\x80-\\xBF\
\x80-\\xBF]/", "", $string);
                        // Strips blank spaces from the beginning/end of a 
string
                        $cleaned = preg_replace('/^[  ]*(.*?)[  ]*$/u', '$1', 
$cleaned);
                        // Strips tags from a string
                        $cleaned = preg_replace('/[\<\>\(\)\{\}\[\]]/u', '$1', 
$cleaned);
                return $cleaned;
        }




Thanks again for your work!








--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to