WordPress.org

Make WordPress Core

Opened 2 months ago

Last modified 2 months ago

#49292 assigned defect (bug)

Fix javascript error caused by incorrectly escaped url

Reported by: juliastri Owned by: juliastri
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.3.2
Component: Script Loader Keywords: reporter-feedback close
Focuses: javascript Cc:

Description

This error message appears in the console on all pages in wp-admin:

Uncaught SyntaxError: missing ) after argument list

It is caused by this line, as seen in the browser console:

<script>
( "fetch" in window ) || document.write( "<script src="http://wv5.local.com/wp-includes/js/dist/vendor/wp-polyfill-fetch.min.js?ver=3.0.0"></scr" + "ipt>" );( document.contains ) || document.write( "<script src="http://wv5.local.com/wp-includes/js/dist/vendor/wp-polyfill-node-contains.min.js?ver=3.26.0-0"></scr" + "ipt>" );( window.FormData && window.FormData.prototype.keys ) || document.write( "<script src="http://wv5.local.com/wp-includes/js/dist/vendor/wp-polyfill-formdata.min.js?ver=3.0.12"></scr" + "ipt>" );( Element.prototype.matches && Element.prototype.closest ) || document.write( "<script src="http://wv5.local.com/wp-includes/js/dist/vendor/wp-polyfill-element-closest.min.js?ver=2.0.2"></scr" + "ipt>" );
</script>

Attachments (3)

console.PNG (10.6 KB) - added by juliastri 2 months ago.
The error message
sources.PNG (22.3 KB) - added by juliastri 2 months ago.
The code that appears in sources
49292.diff (642 bytes) - added by juliastri 2 months ago.
patch file attached

Download all attachments as: .zip

Change History (6)

@juliastri
2 months ago

The error message

@juliastri
2 months ago

The code that appears in sources

#1 in reply to: ↑ description @juliastri
2 months ago

Replying to juliastri:

This error message appears in the console on all pages in wp-admin:

Uncaught SyntaxError: missing ) after argument list

It is caused by this line, as seen in the browser console:

<script>
( "fetch" in window ) || document.write( "<script src="http://wv5.local.com/wp-includes/js/dist/vendor/wp-polyfill-fetch.min.js?ver=3.0.0"></scr" + "ipt>" );( document.contains ) || document.write( "<script src="http://wv5.local.com/wp-includes/js/dist/vendor/wp-polyfill-node-contains.min.js?ver=3.26.0-0"></scr" + "ipt>" );( window.FormData && window.FormData.prototype.keys ) || document.write( "<script src="http://wv5.local.com/wp-includes/js/dist/vendor/wp-polyfill-formdata.min.js?ver=3.0.12"></scr" + "ipt>" );( Element.prototype.matches && Element.prototype.closest ) || document.write( "<script src="http://wv5.local.com/wp-includes/js/dist/vendor/wp-polyfill-element-closest.min.js?ver=2.0.2"></scr" + "ipt>" );
</script>

Note:
I know how to fix it.
The problem is in wp-includes/script-loader.php file where the escaped string inside $polyfill is not rendered correctly.

@juliastri
2 months ago

patch file attached

#2 @ocean90
2 months ago

  • Component changed from General to Script Loader
  • Keywords reporter-feedback added

Hello @juliastri, welcome to WordPress Trac!

Thanks for your report. Are you using a custom plugin or something else which modifies the HTML output? Because by default, as you can see in your patch, the string starts with a single quote mark (') and not a double quote mark (") which shouldn't cause this issue.

#3 @desrosj
2 months ago

  • Keywords close added

I'm also unable to reproduce this.

@juliastri are you using version 5.3.2? trunk?

Going to add close pending more feedback.

Note: See TracTickets for help on using tickets.