Problem/Motivation
jQuery Cookie 1.4.1 is no longer in development, has vulnerabilities and widespread usage in D7 community as a core requirement. JS-Cookie is the replacement used by Drupal 9 with its a shim to translate functions between the two. Lets enable JS-Cookie using this module by providing the shim and admin updates to supply the JS-Cookie path when desired.
Steps to reproduce
- Use jQuery 3.7.0 and all latest versions of dependencies
- Enable jQuery Migrate
- Update jQuery Cookie path with one from JS-Cookie https://cdn.jsdelivr.net/npm/js-cookie@3.0.5/dist/js.cookie.min.js
Without this patch you will discover console errors with "$.cookie is not a function", thus stopping JS from continuing.
Proposed resolution
Add a JS-Cookie shim to this module that is used when a js.cookie url is used. Also admin updates to help get JS-Cookie visible as an option.
Remaining tasks
- Testing of Shim usage as this was stolen directly from Drupal 9.5.10
User interface changes
- Admin descriptions that include jQuery Cookie and JS-Cookie URLs
API changes
- JS-Cookie version checking and URL's in descriptions
- Autoloading of Drupal 9.5.10 js.cookie.shim.js
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | js-cookie-shim-3382000-5.patch | 11 KB | whthat |
Issue fork jquery_update-3382000
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
whthat commentedComment #4
whthat commentedComment #5
whthat commentedWith updated tests as descriptions were changed on Cookie path
Comment #6
whthat commentedComment #7
whthat commentedComment #9
mcdruid commentedInteresting suggestion, thanks.
I think this looks good.
I'd like to see a couple of tweaks:
(nit - there's an extra space before the variable within the
ifcondition.)It's probably okay to check for this string in the custom path, but that could easily go wrong e.g. if someone stores a local copy of the library and renames it without that exact pattern.
If we're going to rely on the presence of that string, let's be explicit about it (in the admin UI), or let's add a checkbox instead to indicate that the shim should be included... that might also give us some space in the admin UI to better explain what this is all about.
Finally, it'd be great to see some additional testing of this option being used.
Comment #10
prabuela commentedComment #11
prabuela commentedComment #12
whthat commentedQuick update based on @mcdruid #9. Further explanation of this experimental option, path requirements and link to Drupal 9 Shim. Happy to go deeper with a checkbox in admin interface, if necessary.
Agreed please test! I have only Drupal core based cookies needs, so any custom/module based cookie code would be ideal.
Comment #13
poker10 commentedCurrently the MR is failing tests, so I think we need to fix that failure first. Thanks!
Comment #14
whthat commentedI need help modifying that test...changed description of field and tried updating, but something else is needed.
Comment #15
mcdruid commentedThe MR still has the "in early testing" wording in the admin UI (see #9) and IMHO putting *** into the admin text for emphasis looks quite messy. Let's try to keep everything as clean and simple as possible.
We also mentioned adding a checkbox for the shim rather than relying on detecting a string in the custom path.
Finally... should the shim still be based on Drupal 9.5? Is it still in D11? If so, can we update the shim and any references, or explain why it's specifically a D9 shim we're including if there's a reason for it to be "locked" etc..
Comment #16
mcdruid commentedThere are a few things to address in the comments, plus needs tests.
Comment #17
mcdruid commentedI had a bit of time to tidy this up, but I'd still like to see some new tests added to verify that e.g. the checkbox / variable for the shim works as it's supposed to.
So leaving at NW + Needs tests for now.