Make WordPress Core

Opened 18 years ago

Closed 11 years ago

#7045 closed defect (bug) (wontfix)

No name shortcode atts

Reported by: viper007bond's profile Viper007Bond Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.6
Component: Shortcodes Keywords: reporter-feedback
Focuses: Cc:

Description

If you have a shortcode with an attribute with no name, it isn't parsed quite correctly:

[shortcode="foo"]bar[/shortcode]

The attributes array ends up with this:

$atts = array( 0 => '="foo"' );

rather than just foo.

Attachments (2)

7045.diff (731 bytes) - added by kovshenin 13 years ago.
7045.unit-tests.diff (981 bytes) - added by kovshenin 13 years ago.

Download all attachments as: .zip

Change History (11)

#1 @Denis-de-Bernardy
17 years ago

  • Component changed from General to Shortcodes
  • Owner anonymous deleted

#2 @ryan
16 years ago

  • Milestone changed from 2.9 to Future Release

#3 follow-up: @sivel
16 years ago

  • Cc matt@… added
  • Keywords reporter-feedback added

Is it common for someone to put that '=' in there? In each case I have seen a shortcode of this nature it's used as:

[shortcode "foo"]bar[/shortcode]

or

[shortcode "foo"]

#4 in reply to: ↑ 3 @Viper007Bond
15 years ago

Replying to sivel:

Is it common for someone to put that '=' in there?

I've never seen [shortcode "foo"], but either way it's a legit bug. ;)

Most of the times I've run into this though are when I'm supporting WP.com's old fake shortcode format that used this style a lot in a plugin of my own.

#5 @Viper007Bond
13 years ago

Tested, this ticket is still valid.

@kovshenin
13 years ago

#6 @kovshenin
13 years ago

  • Keywords has-patch added; needs-patch reporter-feedback removed

7045.diff covers both scenarios:

[shortcode=foo]
[shortcode="foo"]

Passes the existing unit tests, and the two tests added in 7045.unit-tests.diff. You'll have to check how WP.com's "fake shortcodes" adapt to this, but since we're probably doing ltrim in most cases, my guess is that it's going to be fine.

#7 @aaroncampbell
11 years ago

  • Keywords reporter-feedback added; has-patch removed

I have a feeling that this really isn't an actual problem. In the last 5 years it looks like "supporting WP.com's old fake shortcode format" was pretty much the only time this "issue" was hit, and it probably wasn't that hard to code around.

Here are all the samples I looked at and the attributes they get:

[test-7045=foo]
array(1) {
  [0]=>
  string(4) "=foo"
}

This seems like a really rare issue, and it's a misformatted shortcode. All you need to do though is ltrim the =

[test-7045="foo"]
array(1) {
  [0]=>
  string(6) "="foo""
}

This also seems rare and is also misformatted. It requires a little more cleanup, but still the problem is really that this shortcode is wrong (and as far as I can tell, we've never said otherwise).

[test-7045 foo]
array(1) {
  [0]=>
  string(3) "foo"
}

This is actually properly formatted and I've definitely seen this used before. This is really the only one here that I think we should consider fixing, and even then I'm tempted to just say that foo being seen as a parameter value rather than a parameter name is fine. Thoughts?

[test-7045 "foo"]
array(1) {
  [0]=>
  string(3) "foo"
}

This is actually properly formatted and I've definitely seen this used before, but treating the foo as a parameter value rather than a parameter seems sane when it's quoted.

#8 @Viper007Bond
11 years ago

As the reporter, I'm fine closing this wontfix. It's edge case and the wrong usage of shortcodes. If someone needs to parse this wrong format, then it's on them.

#9 @Viper007Bond
11 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.