Skip to content

URL-encoded parameters may break during conversion #41

Description

@PRGfx

The fusion object uses the Guzzle URI to sanitize the created URL (as introduced with bdc511a):

public function convertMailLink($matches)
{
// make sure that URL parameter dividers (`&`) are not encoded
$email = html_entity_decode(trim($matches[2]), ENT_QUOTES | ENT_HTML5);
$replacedHrefContent = $this->mailToHrefConverter->convert($email);
$uri = new \GuzzleHttp\Psr7\Uri($replacedHrefContent);
return $matches[1] . (string)$uri;
}

Given a URL like mailto:test@example.com?subject=hello%20world the obfuscation may rotate the numbers to a character sequence, the Guzzle URI will not recognize as %[A-Fa-f0-9]{2} and escape instead:

// Uri::filterQueryAndFragment

return preg_replace_callback(
    '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/',
    [$this, 'rawurlencodeMatchZero'],
    $str
);

If the de-obfuscation than tries to replace everything back, we get wrong characters.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions