Hi Jake, thanks once more!
I have just performed the following measures:
Seeded the following code in the main initialisation of the
Ajaxify code:
- $.log("htmlPrefilter : " + $.htmlPrefilter);
That correctly returns the default function body of htmlPrefilter as expected (I am using jQuery version 1.12.4).
(Let's not bother, what the default function is)
I then overrode the default function body as follows in the same main initialisation, just above the previous line:
- $.htmlPrefilter = function( html ) { return html; }
The above $.log() message shows the new function correctly.
Finally I enabled some code known to trigger the error in a social media plugin (function csbwfsGetCookie):
- ...for(var i=0; i<ca.length; i++) {...
The above code is within an inline script.
Unfortunately, the result is the same... (I get a hard error)
What's happening when loading the target page, via Ajax and then into the jQuery selector, is that the "less than sign" within the for loop is being interpreted as an opening tag by jQuery.
If I place a space after the "less than sign" everything works fine (!)
I've left the erroneous logic alive at the moment on
4nf.org. (have a look at the console when switching pages)
I would like to re-iterate a bounty of €100, payable via PayPal for any decisive help, leading to the resolution of the bug...
------------------------------
Additional information:
The same bug happens with the
inline script of the Emoji logic, enabled by default in Wordpress... So the bug pertains to all Wordpress users unless they disable the default logic
------------------------------
EDIT: I think, I know what it is:
The Ajaxify plugin escapes scripts, whether external or inline to
- <ajy-script>...</ajy-script>
...before dumping the whole page into the jQuery selector...
....so the jQuery parser has no fair chance to treat inline script contents as usual...
The most elegant solution would be, not to escape script tags at all. Do you think that that is viable?
At the moment, the plugin is escaping:
- html
- head
- body
- link and
- script
tags, so that the jQuery selector can "digest" the target page
I can see two follow-up questions:
- Can the jQuery parser handle script tags at the top level (i.e. without parent tags)?
- How can one prevent the scripts from being fired?