Hi,
That slash-escaping was working before, but I guess one or more recent
changes have broken it. Good catch, and fix - yes, feel free to check it in.

-Yaron

On Wed, Dec 17, 2008 at 6:10 AM, Serhiy Kutnii <[email protected]> wrote:

>
> Hi everybody!
>
> I've found that the SemanticForms' autocompletion javascript crashes
> if the values list contains values with quotes. Here's the info from
> Firefox error console:
>
> "Error: missing ] after element list
> [...]
> [...['Amagat's law']...]" - it crashes on this "Amagat's law" value.
>
> I'm using autocompletion on concept so the values are taken from the
> wiki automatically.
>
> I've looked into the sources and that's what I found:
> createAutocompleteValuesArray function from SF_FormInputs.inc uses
> sffGetAllPagesForNamespace global function (SF_GlobalFunctions.php)
> and sffGetAllPagesForNamespace constructs the values as follows:
>
>                        while ($row = $db->fetchRow($res)) {
>                                $cur_value = str_replace('_', ' ', $row[0]);
>                                if ($substring == null) {
>                                        $pages[] = str_replace("'", "\'",
> $cur_value);
>                                } else {
>                                        $pages[] = array('title' =>
> $cur_value);
>                                }
>                        }
>
> So when the values are printed to the output they'll contain just
> plain quotes but these must be protected with slashes in the
> Javascript code. The slashes must be added twice.
>
> I've replaced "return $names_array;" in the
> createAutocompleteValuesArray with "return array_map('addslashes',
> $names_array);". This solved the crash problem. I've seen the
> autocompletion working.
>
> So is it OK to commit this?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Semantic Forms" 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/semantic-forms?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to