Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regular parser throws exception with param=0 #74

Closed
rhukster opened this issue Feb 1, 2019 · 4 comments
Closed

regular parser throws exception with param=0 #74

rhukster opened this issue Feb 1, 2019 · 4 comments
Assignees
Labels

Comments

@rhukster
Copy link

rhukster commented Feb 1, 2019

While debugging an issue with the Grav Shortcode UI plugin: (getgrav/grav-plugin-shortcode-ui#29) I discovered the regular parser will skip over an x param with the following format: [shortcode x=0].

[shortcode x="0"] works, as well as [shortcode x=1], but not x=0. This only seems to affect the regular parser. It works fine and as expected with regex and wordpress parsers.

I gave it a quick debug and it seems like the match() method in the regular parser is trying to match the wrong type (6 vs 5?). I dunno, it's a bit hard for me to fully debug this as I'm not super familiar with this tokenized parser.

The result is the parent shortcode is completely skipped, causing child shortcodes to not have a parent, hence the exception to be thrown. This seems like a pretty nasty issue as any shortcode with x=0 type params will just be skipped entirely.

@thunderer
Copy link
Owner

Hi @rhukster, thanks for the report. The actual problem is in how PHP handles value comparison, especially for string '0' (the only falsy non-empty string). RegularParser didn't take this edge case into account, which caused exactly the behavior you described. I fixed this issue in #75, please test it on your side and tell me whether it fixes all your issues.

@thunderer thunderer self-assigned this Feb 1, 2019
@thunderer thunderer added the bug label Feb 1, 2019
@rhukster
Copy link
Author

rhukster commented Feb 1, 2019

Thanks for the prompt reply (as usual). Just tested the PR and it resolves the problems. Thanks!

Andy

@rhukster rhukster closed this as completed Feb 1, 2019
@thunderer
Copy link
Owner

@rhukster tagged v0.7.1.

@rhukster
Copy link
Author

rhukster commented Feb 4, 2019

Great, i'll get an update of shortcode-core Grav plugin asap. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants