Skip to content

Fix regex to match quoted parameters in parseParams function#209

Open
fadrian06 wants to merge 2 commits into
EFTEC:masterfrom
fadrian06:fix/component-with-prop-with-spaces
Open

Fix regex to match quoted parameters in parseParams function#209
fadrian06 wants to merge 2 commits into
EFTEC:masterfrom
fadrian06:fix/component-with-prop-with-spaces

Conversation

@fadrian06

@fadrian06 fadrian06 commented Jun 26, 2026

Copy link
Copy Markdown

This pull request updates the parameter parsing logic in the parseParams method to better handle quoted parameter values. The regular expression used for matching parameters now supports values wrapped in either single or double quotes, improving robustness when parsing parameters with spaces or special characters.

Improvements to parameter parsing:

  • Updated the regular expression in parseParams to correctly match parameter values enclosed in single or double quotes, enhancing support for complex parameter values.

Update regex to match quoted parameters in parseParams function.
Copilot AI review requested due to automatic review settings June 26, 2026 20:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates BladeOne’s <x-...> component attribute parsing by changing parseParams() to only match quoted attribute values, improving extraction accuracy and avoiding accidental captures.

Changes:

  • Tightened the parseParams() regex to require attribute values to be enclosed in either single or double quotes.
Comments suppressed due to low confidence (1)

lib/BladeOne.php:3040

  • The updated regex now matches single-quoted values, but the extraction logic only removes double quotes. This leaves surrounding single quotes in $value, producing incorrect compiled params (and can generate invalid PHP when the value contains embedded double-quotes). Strip only the outer matching quote and use a proper PHP string literal for non-: attributes (e.g., via var_export).
        preg_match_all('/([a-zA-Z0-9:-]*?)\s*?=\s*?("?.+?"?|\'?.+?\'?)(\s|$)/ms', $params, $matches);
        $paramsCompiled = [];
        foreach ($matches[1] as $i => $key) {
            $value = str_replace('"', '', $matches[2][$i]);
            //its php code

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/BladeOne.php Outdated
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

Successfully merging this pull request may close these issues.

2 participants