[wp-trac] [WordPress Trac] #31471: shortcode_parse_atts has no escape sequence to handle literal quotes within values

WordPress Trac noreply at wordpress.org
Wed Mar 4 00:53:37 UTC 2015


#31471: shortcode_parse_atts has no escape sequence to handle literal quotes within
values
--------------------------+------------------------------
 Reporter:  maximinime    |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Shortcodes    |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by maximinime):

 An alternative sequence is the good ol' doubling of quotes, which my be
 more backwards-compatible since the current pattern just matches such
 input as a single attr/value string, rather than a pair.

 {{{
 $pattern =
 '/(\w+)\s*=\s*"([^"]*(?:""[^"]*)*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*(?:\'\'[^\']*)*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*(?:""[^"]*)*)"(?:\s|$)|(\S+)(?:\s|$)/';
 }}}

 This would allow escaping of input like so: {{{title="<a
 href=""/foo/"">Bar</a>"}}}. The doubled quotes would have to be removed
 from the input after {{{stripcslashes()}}}, but that's a simple
 {{{str_replace('""', '"', ...)}}} or {{{str_replace("''", "'", ...)}}}
 depending on which quote style was matched.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31471#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list