[wp-trac] [WordPress Trac] #35591: Shortcode Attributes Parsing Issue

WordPress Trac noreply at wordpress.org
Sun Jan 24 14:03:40 UTC 2016


#35591: Shortcode Attributes Parsing Issue
----------------------------+------------------------------
 Reporter:  markclotfelter  |       Owner:
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Shortcodes      |     Version:  4.4.1
 Severity:  normal          |  Resolution:
 Keywords:  close           |     Focuses:
----------------------------+------------------------------

Comment (by markclotfelter):

 Just to clarify, what i meant by "ALL OF THEM" was in reference to
 stripping way the first layer of quotes for ALL VARIABLES. Stripping away
 the first layer is expected behavior; leaving them, is not.
 (the results of an unbiased parser should be uniform)

 Replying to [comment:2 markclotfelter]:
 > i understand the concept of what the parser is doing. i didn't expect it
 to give me an integer.
 > my point is that what it returned had quotes attached to it (wrapped
 around it) when i went to use that variable. (that's NOT fully successful
 parsing) The other variables i've used do NOT have quotes.
 > the initial quotes around anything being passed as attributes to a
 shortcode should get all outside quotes stripped from them... ALL OF THEM.
 And, it should be uniform.
 >
 > Replying to [comment:1 swissspidy]:
 > > Shortcode attributes are strings, no matter what you pass them. The
 parser can't know what you expect to be returned and `expert="123"`is no
 different than `expert="abc"`.
 > >
 > > In your example, `$atts['expert']` would be `'142'` (a string). If you
 need an integer value, just use `(int)` or `absint()`. The same goes for
 boolean flags like `foo="true"` or `bar="false"`. You should cast the
 types explicitly.
 > >
 > > Ps. I wouldn't recommend using `extract()` as it makes debugging more
 difficult.
 >

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


More information about the wp-trac mailing list