Make WordPress Core

Opened 8 years ago

Closed 10 months ago

#43403 closed enhancement (wontfix)

Improve wp_add_inline_script()

Reported by: alpipego's profile alpipego Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Script Loader Keywords:
Focuses: Cc:

Description

Just an idea for the moment:

Instead of testing if the js has script tags and adding an error messages but also fixing the problem at the same time, why not accept both. If the passed data has tags just leave them (this would potentially fix #40276) and if not surround the code with plain <script> tags.

Change History (1)

#1 @jonsurrell
10 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Thanks, this is a reasonable idea, however there are some difficulties.

Primarily, it isn't easy to recognize where a script tag and ends. The current implementation is insufficient in that regard. There's a related change where the HTML_Tag_processor should be used to find the script contents in the case that it appears a script tag was provided.

I'd be reluctant to make the change as described in this ticket becaue it can be problematic to print script tags that aren't vetted for correct escaping. That leads to issues like #62797.

Note: See TracTickets for help on using tickets.