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

Plugin tries to process non Shortcode files (custom shortcodes) #127

Open
chraebsli opened this issue Oct 3, 2024 · 0 comments
Open

Plugin tries to process non Shortcode files (custom shortcodes) #127

chraebsli opened this issue Oct 3, 2024 · 0 comments

Comments

@chraebsli
Copy link

Problem

Recently, I've had an error that the Shortcode plugin somehow tried to process a .gitkeep file in the custom shortcodes folder specified with custom_shortcodes.

How I noticed the problem

I don't know why and how, but my .gitkeep file had two empty lines instead of just one by accident, and that caused a single empty line at the top of every page. After I removed the new line or disabled the plugin, the problem was gone.

Security

This issue could be a bigger security risk, since the plugin parses files which are not meant to be a shortcode.

Possible solution

Since all shortcodes are built like this:,

class CustomShortcode extends Shortcode {
    public function init() {
        $this->shortcode->getHandlers()->add('custom', function (ShortcodeInterface $sc) {
            return 'some custom content';
        });
    }
}

I think it must be possible to only "parse" shortcode files. Or even only executing PHP code which is a class and extends Shortcode.


I'm not very familiar with PHP yet, so this could be a wrong assumption, but why was the plugin built this way? Isn't it easier to just run child classes of Shortcode

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

No branches or pull requests

1 participant