WordPress.org

Make WordPress Core

Changes between Initial Version and Version 5 of Ticket #42730


Ignore:
Timestamp:
11/29/2017 12:07:26 PM (4 years ago)
Author:
SergeyBiryukov
Comment:

Replying to MattyRob:

It seems my library is queuing correctly - it just looks weird in the source when you check back to make sure it's queued right.

Right, the encoded ampersand won't work in the address bar, but should work as expected in the page source.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #42730

    • Property Status changed from new to closed
    • Property Resolution changed from to invalid
    • Property Component changed from General to Script Loader
    • Property Version changed from trunk to
    • Property Milestone changed from Awaiting Review to
    • Property Type changed from enhancement to defect (bug)
  • Ticket #42730 – Description

    initial v5  
    33This causes issues if the URL contains parameters, for example `https://api.ipify.org?format=jsonp&callback=getip`. This gets turned into `https://api.ipify.org?format=jsonp#038;callback=getip` and results in failure of the script.
    44
    5 I think I've tracked this down to the `do_item()` function of the wp-includes/class.wp-scripts.php file. In here the `script_loader_src `
    6  is called on 2 occasions, once the returned value is left unescaped and once it is passed through `esc_url()`. It is the latter application of the filter that escapes the ampersand and breaks the URL to the javascript file.
     5I think I've tracked this down to the `do_item()` function of the wp-includes/class.wp-scripts.php file. In here the `script_loader_src` is called on 2 occasions, once the returned value is left unescaped and once it is passed through `esc_url()`. It is the latter application of the filter that escapes the ampersand and breaks the URL to the javascript file.
    76
    87Should the call to the `esc_url()` be removed to allow parameters in the URLs or is there another way to '''enqueue''' such scripts that I have not yet found (currently I'm just hooking to wp_head and echoing the script).