theme-check icon indicating copy to clipboard operation
theme-check copied to clipboard

Parsedown class false positive for short tags

Open danyj opened this issue 7 years ago • 4 comments

I am just reopening this since the post here https://github.com/WordPress/theme-check/issues/64 is over a year old .

@Otto42 how big of a change would it be on theme check side? Minor as in parsedown or ? Asking because parsedown dev refereed https://github.com/erusev/parsedown/issues/469#issuecomment-275927418 me back here and I hate to change their original class because of maintenance issues.

So if either of you guys could make the change it would be great.

Thank you!

danyj avatar Jan 29 '17 17:01 danyj

~~Please can you explain why you can just the normal tags?~~~

Edit: I see now that the reason is from https://github.com/erusev/parsedown/issues/469 We are working on a new update of the Theme Check plugin which we hope to release within the next 5 months. It is not likely we will be making any changes to the old code. You can test the new version here https://github.com/ernilambar/ns-theme-check. It already contains the short tags test which should be better than before. Let me know that goes.

From the official documentation https://secure.php.net/manual/en/language.basic-syntax.phptags.php

PHP also allows for short open tag <? (which is discouraged since it is only available if enabled using the short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option).

Your code would break if you use short tags and they were disabled on a server.

grappler avatar Jan 30 '17 07:01 grappler

Your code would break if you use short tags and they were disabled on a server.

no one is using short tags here , this is false positive for regex

tested theme with ns theme check no mention of Parsedown for now

danyj avatar Jan 30 '17 10:01 danyj

It occurs to me that the simplest (and correct) solution is to just check whether an unclosed <?php tag exists in the document before reporting on the short open tag that the check in question returns? (if there were a short tag inside code that is already PHP, the error would be syntactic, and so the file wouldn't run anyway (worse than a standards error)).

Surely parsing characters in a string like a language construct is a pretty major bug?

aidantwoods avatar Jan 30 '17 19:01 aidantwoods

Sorry, I came across a bit harsh in my previous comment as I did not initially realize it was a false positive.

As we are planning of releasing a complete rewrite of this plugin it does not make sense to continue to work on the current code.

grappler avatar Jan 30 '17 21:01 grappler