Drupal 11 ships with jQuery 4: https://www.drupal.org/node/3445202.
This means that jQuery 3 functions that were deprecated have been fully removed and are no longer available. The ParseJSON function in particular affects this module: https://api.jquery.com/jQuery.parseJSON/.
This means that this code will fail on Drupal 11.
We simply have to replace all usages of it with the native JSON.parse() function: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global.... The native JSON parser is supported accross all browsers for a very long, and is very stable. So this is not a breaking change that we only need to do for Drupal 11. It can go into the current module version without any breaking changes.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | autologout-d11-compatibility-3557332-88.patch | 1.71 KB | gueguerreiro |
Issue fork autologout-3557332
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 #3
naveenraj i commentedCategory: Bug report
Title: Fix: Secure JSON parsing (SCA issue) in autologout.js
Proposed resolution
File: js/autologout.js
Issue:
The $.parseJSON() method was used for JSON parsing, which is deprecated and flagged as insecure in Static Code Analysis (SCA).
Resolution:
Replaced $.parseJSON() with a safer and standard JSON.parse() wrapped in a try...catch block to prevent runtime errors.
Branch: 3557332-bug-report-sca
Commit: 9fa186dd
Comment #6
gueguerreiroUpdating this issue since I believe the original title and description don't highlight the severity of the issue for newer sites. I updated the current MR slightly to fix trailing white spaces and some identation issues, but I'm still leaving it as Needs Review because I'm not sure about the inclusion of the "try/catch" approach with a silent error. We might probably want an error somewhere if that portion of the code fails for any reason? Otherwise it might be impossible to detect issues.
Attaching a patch with the fix, if it's useful for anyone.
Comment #8
the_g_bomb commentedThis will need a rebase and the MR should be updated to target the 2.x branch
Comment #9
deaom commentedThis is also already solved in the 2.x branch and can be closed.
2.x. branch does
and the MR does:
Leaving status as is so maintainers can close it out as they wish.
Comment #10
the_g_bomb commentedAs per the previous comment, the other work done has solved this. Please feel free to reopen and update the steps to reproduce if you are still having problems.