Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Umlauts in Search lead to JS-Error. #55

Open
animaux opened this issue Jun 13, 2016 · 28 comments
Open

Umlauts in Search lead to JS-Error. #55

animaux opened this issue Jun 13, 2016 · 28 comments

Comments

@animaux
Copy link
Contributor

animaux commented Jun 13, 2016

When using the search term schö for example an error is thrown and the search is not successful:

TypeError: undefined is not an object (evaluating 'a.length')
@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

This results in Strange behaviour:

If I try to look for an entry named Hänigsen the above error will prevent a successful search as soon as the »ä« comes into play.

However, if I type nigsen, the entry is succefully found and presented. After that I can even start a new search with the search term Hän… actually working.

I suspect there is some encoding problem happening during typing or search submission. I wonder if @nilshoerrmann has has this problem too? :)

@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

Not sure if the extension or symphony is at fault.

bildschirmfoto 2016-12-14 um 09 13 19

@nilshoerrmann
Copy link
Contributor

No, I haven't encountered this issues yet.

@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

Hmpfdgnf. Danke :)

@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

Apparently the problem seems to be with Umlauts in the first 3 characters of a search term.

@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

Using a reflection field instead of a text field for the association makes me able to find the Umlaut-Entries but still throws the error.

@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

Hmmm. Can’t reproduce the error on a copy of the SOR site trying several versions of AI Editor and the Association field itself. Must be some other extension gretching in.

@nilshoerrmann
Copy link
Contributor

The search is powered by Selectize that is bundled with Symphony (or at least was – I'm not sure how this is handled in the latest releases). Maybe Selectize was updated in the core resulting in compatibility issues?

@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

I have used an updated version of selectize in my fork-set that overrides the bundled one:

https://github.com/animaux/association_ui_selector
https://github.com/animaux/association_ui_editor

Installing those does not break the SOR-Site either … must be something else in play.

@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

Really beats me. I’ve copied all the extensions, symphony-folder and rebuilt the section/link-structure from a site with the error but still can’t reproduce it. ¯_(ツ)_/¯

@nilshoerrmann
Copy link
Contributor

Have you tried another browser?
Have you checked which line is causing the error?

@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

bildarchiv archivrh de
goldwiege de
fotoarchiv animaux de

@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

And Firefox Dev:

bildschirmfoto 2016-12-14 um 11 55 16

@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

Not really helping because the files mentioned are identical on two sites. One has the error. One not.

@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

Extensions are identical too. Site structure. I’m struggling to find the difference …

@twiro
Copy link

twiro commented Dec 14, 2016

I don't think the problem is caused by the extension itself - I remember having some filtering trouble with umlauts in the publish filtering feature (which also relies on selectize) too. And as far as I can remember I was getting similar javascript-errors as the ones you're posting.

I did some tests back then, compared datasource filtering with publish filtering and noticed that there are really a lot of quirks regarding filtering umlauts and special characters. Regarding selectize I even noticed differences in typing a character and using the proposed autocomplete-values.

You can see the results for the basic input-field here.

I submitted a PR that fixes the filtering-bugs number-field has (will be in 2.7), but didn't dig deeper into the umlaut-issues...

@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

Thanks Roman.

@nilshoerrmann
Copy link
Contributor

That's a great test, Roman.
You should notify @nitriques and @brendo about the results (if you haven't done this already).

@twiro
Copy link

twiro commented Dec 14, 2016

That's a great test, Roman.

Thank you! I got inspired by this page in the wiki and thought it would be cool to have this kind of overview for all (core) fields.

You should notify @nitriques and @brendo about the results (if you haven't done this already).

You bet I did - but I guess there are no resources left at the moment to take care of things like these. Though these documented tests would probably be of great help if someone really wanted to start fixing these bugs one by one... as proposed in the post linked above one could start to file separate issues for the separate bugs, but I didn't want to flood symphony's issue tracker with a ton of "edge case issues" that probably won't get fixed for a looong time.

But I do hope to get back to these tests some day, update them and maybe try fixing some of the more problematic issues myself. I also think it would be a great addition to some extensions to directly add these filtering-test-reports to the extension repository (the way I did with slider field) - helps giving a better understanding of what each field's filtering capabilities (and shortcomings/bugs) are.

But for now... enough issue-hijacking ;)

@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

But for now... enough issue-hijacking ;)

No worries, good thing you did.

I’ve checked the DB encoding too. Same.

@animaux
Copy link
Contributor Author

animaux commented Dec 14, 2016

.htaccess and config.php are also not the problem …

@nitriques
Copy link

@animaux curious to see how Chrome handles it. Same error ? I know for a fact that Safari uses UTF-16 in their jscore implementation. But seeing that the error is in jquery itself puzzle me a lot. But again, PHP has not internal encoding (it's just binary data) but you can "format" that binary code to whatever you want.

Are the sites both on the same server ? Same php.ini file ?

@nitriques
Copy link

@twiro

but I guess there are no resources left at the moment to take care of things like these.

Yeah, sadly. We got "big" clients this year which means we are doing more maintenance that what we've planned, which reduced my "free" time, both at work and at home. But dealing with encoding always was and still is a pain. I wonder how other systems handle those cases, but from my experience, it's not really better.

@nitriques
Copy link

nitriques commented Dec 16, 2016

And this is worth reading: http://softwareengineering.stackexchange.com/a/151296

strlen is encoding-agnostic and assumes a fixed-width 8 bit encoding, that is, one byte per character, so it will count bytes, not characters.

Make sure to use General::strlen() and have mb_string installed.

@animaux
Copy link
Contributor Author

animaux commented Dec 16, 2016

Are the sites both on the same server ? Same php.ini file ?
Yes, absolutely.

And it’s the same in chrome:

skjermbilde 2016-12-16 kl 19 18 52

@animaux
Copy link
Contributor Author

animaux commented Dec 16, 2016

I’m not sure entirely it’s an encoding problem since the error comes up as well if I type in at least three standard ascii characters. But in that case the search seems to work.

@animaux
Copy link
Contributor Author

animaux commented Dec 21, 2016

@jonmifsud’s suggestion helped solve the Umlaut-issue:

change line 12 of association_ui_selector/content/content.query.php to
$search = General::sanitize(urldecode($_GET['query']));

About the error:

in line 215 of the JS there should be a check if result.entries is populated

So that's the basic recipe to fix this problem :)

@animaux
Copy link
Contributor Author

animaux commented Jan 31, 2017

Fixed in #57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants