Opened 18 years ago
Closed 11 years ago
#7045 closed defect (bug) (wontfix)
No name shortcode atts
| Reported by: |
|
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)
Change History (11)
#4
in reply to:
↑ 3
@
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.
#6
@
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
@
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.
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:
or