0

When I try to submit the default contact us form, this is the error that I get.

Warning: preg_replace(): Compilation failed: invalid range in character class at offset 39 in /home/hudsonpa/public_html/xxxxx/vendor/pelago/emogrifier/Classes/Emogrifier.php on line 1507

Anybody knows what this is?

This is the form

<form class="form contact"
                  action="<?= $block->escapeUrl($block->getFormAction()) ?>"
                  id="contact-form"
                  method="post"

On inspecting the final html, it points to

<form class="form contact" action="https://domain.com/xxxx/index.php/contact/index/post/" id="contact-form" method="post" style="float:unset; width:unset;" data-hasrequired="* Required Fields" novalidate="novalidate">

--- edit --- added screenshot enter image description here

--- edit 2 ---

Also found the Emogrifier.php line 1507 has this

        $roughXpath = preg_replace(array_keys($this->xPathRules), $this->xPathRules, $trimmedLowercaseSelector);

and the $xPathRules array looks like this

private $xPathRules = [
        // attribute presence
        '/^\\[(\\w+|\\w+\\=[\'"]?\\w+[\'"]?)\\]/' => '*[@\\1]',
        // type and attribute exact value
        '/(\\w)\\[(\\w+)\\=[\'"]?([\\w\\s]+)[\'"]?\\]/' => '\\1[@\\2="\\3"]',
        // type and attribute value with ~ (one word within a whitespace-separated list of words)
        '/([\\w\\*]+)\\[(\\w+)[\\s]*\\~\\=[\\s]*[\'"]?([\\w-_\\/]+)[\'"]?\\]/'
        => '\\1[contains(concat(" ", @\\2, " "), concat(" ", "\\3", " "))]',
        // type and attribute value with | (either exact value match or prefix followed by a hyphen)
        '/([\\w\\*]+)\\[(\\w+)[\\s]*\\|\\=[\\s]*[\'"]?([\\w-_\\s\\/]+)[\'"]?\\]/'
        => '\\1[@\\2="\\3" or starts-with(@\\2, concat("\\3", "-"))]',
        // type and attribute value with ^ (prefix match)
        '/([\\w\\*]+)\\[(\\w+)[\\s]*\\^\\=[\\s]*[\'"]?([\\w-_\\/]+)[\'"]?\\]/' => '\\1[starts-with(@\\2, "\\3")]',
        // type and attribute value with * (substring match)
        '/([\\w\\*]+)\\[(\\w+)[\\s]*\\*\\=[\\s]*[\'"]?([\\w-_\\s\\/:;]+)[\'"]?\\]/' => '\\1[contains(@\\2, "\\3")]',
        // adjacent sibling
        '/\\s+\\+\\s+/' => '/following-sibling::*[1]/self::',
        // child
        '/\\s*>\\s*/' => '/',
        // descendant
        '/\\s+(?=.*[^\\]]{1}$)/' => '//',
        // type and :first-child
        '/([^\\/]+):first-child/i' => '*[1]/self::\\1',
        // type and :last-child
        '/([^\\/]+):last-child/i' => '*[last()]/self::\\1',

        // The following matcher will break things if it is placed before the adjacent matcher.
        // So one of the matchers matches either too much or not enough.
        // type and attribute value with $ (suffix match)
        '/([\\w\\*]+)\\[(\\w+)[\\s]*\\$\\=[\\s]*[\'"]?([\\w-_\\s\\/]+)[\'"]?\\]/'
        => '\\1[substring(@\\2, string-length(@\\2) - string-length("\\3") + 1) = "\\3"]',
    ];

When i individually take the patterns and compile them, there seems to be a problem in the third pattern (and a few others) at this spot

[\\w-_\\/]+

If I change it to

[\\w\\-_\\/]+

Then the pattern compiles.

Is this a good move?

2
  • 1
    can you share a screenshot?
    – Mohit Rane
    Commented Jul 13, 2019 at 6:12
  • 1
    @MohitRane, I added a screenshot. Thanks for stopping by,
    – Mark CR
    Commented Jul 13, 2019 at 6:54

1 Answer 1

0

Checked out the Emogrifier code in its github repo.

https://github.com/MyIntervals/emogrifier/blob/master/src/Emogrifier.php

Refreshed my file with that code. All works fine now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.