In the system preference there is a console error when you select the 'Searching' tab or go to: http://localhost:8081/cgi-bin/koha/admin/preferences.pl?tab=searching Uncaught Error: Syntax error, unrecognized expression: #collapse_Did_you_mean/spell_checking
Created attachment 114826 [details] [review] Bug 27336: Fix JS error on preferences.pl To test: 1. Go to http://localhost:8081/cgi-bin/koha/admin/preferences.pl?tab=searching 2. If you are on the "Searching" tab you will see a console error 3. Apply patch 4. Make sure the error is gone
This error is caused by the line 'Did you mean/spell checking:' in searching.pref The '/' is the problem so I changed the line to 'Did you mean and spell checking'
Created attachment 114830 [details] [review] Bug 27336: Fix JS error on preferences.pl To test: 1. Go to http://localhost:8081/cgi-bin/koha/admin/preferences.pl?tab=searching 2. If you are on the "Searching" tab you will see a console error 3. Apply patch 4. Make sure the error is gone Signed-off-by: David Cook <dcook@prosentient.com.au>
I don't love this solution, since it's more of a workaround than a fix, but it solves the problem. Another solution would've been to further sanitize the ID in preferences.tt but that's also a bit of a pain to do comprehensively.
It looks like HTML 4 was strict about the value of ID (https://www.w3.org/TR/html4/types.html#type-id). However, HTML 5 doesn't seem to be (https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#the-id-attribute). It looks like the issue arises in the jquery-2.2.3 library in fa.tokenize. Reading the minified JS even with pretty print turned on is a bit of a nightmare. I feel like Chrome might not be processing things quite right in the debugger. In any case, Jquery and CSS2 get more specific about what they allow and do not allow: https://api.jquery.com/category/selectors/ https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier Wow CSS specs are a bigger mess than one would think... For CSS3... I can't make head or tail of the spec in terms of allowed characters. It says how to escape characters but that's about it (https://www.w3.org/TR/css-syntax-3/#escaping). This is vague: https://www.w3.org/TR/css-syntax-3/#typedef-ident-token "Property names and at-rule names are always identifiers, which have to start with a letter or a hyphen followed by a letter, and then can contain letters, numbers, hyphens, or underscores. You can include any code point at all, even ones that CSS uses in its syntax, by escaping it." https://www.w3.org/TR/css-syntax-3/#syntax-description So I suppose another solution would be to implement a template toolkit for CSS selectors... Anyway, enough of this digression... heh
Created attachment 114949 [details] [review] Bug 27336 (alternative): Sanitize correctly HTML id Valid characters are alphanumeric characters (a-zA-Z0-9), hyphen (-) and underscore (_) https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier All invalid characters will be replaced by '_' Test plan: 1. Go to Administration » System preferences and click on 'Searching' tab 2. You should see a console error (Uncaught Error: Syntax error, unrecognized expression: #collapse_Did_you_mean/spell_checking) 3. Apply patch 4. Make sure the error is gone 5. prove t/Koha_Template_Plugin_HtmlId.t
Instead of working around the bug, let's fix it. Back to needs signoff
Created attachment 114952 [details] [review] Bug 27336: (alternative) Sanitize correctly HTML id Valid characters are alphanumeric characters (a-zA-Z0-9), hyphen (-) and underscore (_) https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier All invalid characters will be replaced by '_' Test plan: 1. Go to Administration » System preferences and click on 'Searching' tab 2. You should see a console error (Uncaught Error: Syntax error, unrecognized expression: #collapse_Did_you_mean/spell_checking) 3. Apply patch 4. Make sure the error is gone 5. prove t/Koha_Template_Plugin_HtmlId.t Signed-off-by: Owen Leonard <oleonard@myacpl.org>
I think Julian's patch is a better long-term solution. The QA tool will need to be updated to recognize the new filter.
(In reply to Owen Leonard from comment #9) > I think Julian's patch is a better long-term solution. The QA tool will need > to be updated to recognize the new filter. Agreed, and thank you Julian!
Created attachment 114975 [details] [review] Bug 27336: (alternative) Sanitize correctly HTML id Valid characters are alphanumeric characters (a-zA-Z0-9), hyphen (-) and underscore (_) https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier All invalid characters will be replaced by '_' Test plan: 1. Go to Administration » System preferences and click on 'Searching' tab 2. You should see a console error (Uncaught Error: Syntax error, unrecognized expression: #collapse_Did_you_mean/spell_checking) 3. Apply patch 4. Make sure the error is gone 5. prove t/Koha_Template_Plugin_HtmlId.t Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Created attachment 115006 [details] [review] Bug 27336: Sanitize correctly HTML id Valid characters are alphanumeric characters (a-zA-Z0-9), hyphen (-) and underscore (_) https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier All invalid characters will be replaced by '_' Test plan: 1. Go to Administration » System preferences and click on 'Searching' tab 2. You should see a console error (Uncaught Error: Syntax error, unrecognized expression: #collapse_Did_you_mean/spell_checking) 3. Apply patch 4. Make sure the error is gone 5. prove t/Koha_Template_Plugin_HtmlId.t Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Created attachment 115007 [details] [review] Bug 27336: Add POD for new package
Created attachment 115008 [details] [review] Bug 27336: Fix xt/find-missing-filters.t
Pushed to master for 21.05, thanks to everybody involved!
Pushed to 20.11.x for 20.11.02
I don't see the reported JS error in 20.05. Not backported. Please ask if required.