Summary: | JS error in Administration - System preferences page | ||
---|---|---|---|
Product: | Koha | Reporter: | Lucas Gass (lukeg) <lucas> |
Component: | Staff interface | Assignee: | Julian Maurice <julian.maurice> |
Status: | CLOSED FIXED | QA Contact: | Testopia <testopia> |
Severity: | normal | ||
Priority: | P5 - low | CC: | andrew, caroline.cyr-la-rose, dcook, fridolin.somers, gmcharlt, julian.maurice |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | Small patch |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: |
21.05.00,20.11.02
|
|
Circulation function: | |||
Attachments: |
Bug 27336: Fix JS error on preferences.pl
Bug 27336: Fix JS error on preferences.pl Bug 27336 (alternative): Sanitize correctly HTML id Bug 27336: (alternative) Sanitize correctly HTML id Bug 27336: (alternative) Sanitize correctly HTML id Bug 27336: Sanitize correctly HTML id Bug 27336: Add POD for new package Bug 27336: Fix xt/find-missing-filters.t |
Description
Lucas Gass (lukeg)
2021-01-04 23:09:47 UTC
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. |