Skip to content

Invalid character encoding after content-type header stacking #545

Closed
@valentin-popov

Description

@valentin-popov

Description

If Embed::mustRedirect returns true (this line), the request is repeated and the headers of every response are pushed into an array.

In the Embed\Document constructor, when the content-type header is extracted, the headers array is imploded using a comma as a separator (see this line). However, the comma is not used further as a delimiter during the regex matching, so a comma-suffixed value is passed to Parser::parse as an encoding, causing an error.

Because the comma is used by GuzzleHttp\Psr7\MessageTrait as a separator, it should also be considered when extracting the encoding parameter.

How to replicate

Call get on a google search URL

use Embed\Embed;

$embed = new Embed();

$url = 'https://www.google.com/search?q=linux&sca_esv=91f756f8d95b3a2b&biw=1682&bih=973&sxsrf=ADLYWILZ6bcSGHu7s3LGxCbmaeFwrJP5sw:1730981050201&ei=uqwsZ9buC-mCxc8PjJKL0Qk&ved=0ahUKEwjWs_D0lsqJAxVpQfEDHQzJIpoQ4dUDCA8&uact=5&oq=linux&gs_lp=Egxnd3Mtd2l6LXNlcnAiBWxpbnV4MgoQIxiABBgnGIoFMgQQIxgnMgoQIxiABBgnGIoFMgsQABiABBiRAhiKBTILEAAYgAQYkQIYigUyBRAAGIAEMgUQLhiABDIFEAAYgAQyBRAAGIAEMgUQABiABEi9EFCsC1isD3ADeAGQAQCYAZwBoAHJBKoBAzAuNLgBA8gBAPgBAZgCB6AC5wTCAgcQIxiwAxgnwgIKEAAYsAMY1gQYR8ICDRAAGIAEGLADGEMYigXCAgsQLhiABBjRAxjHAcICEBAuGIAEGNEDGEMYxwEYigXCAgoQABiABBhDGIoFwgITEC4YgAQY0QMYQxjHARjJAxiKBcICChAuGIAEGEMYigXCAgsQABiABBiSAxiKBcICCxAuGIAEGMcBGK8BmAMAiAYBkAYKkgcDMy40oAf1Pg&sclient=gws-wiz-serp'
$info = $embed->get($url);

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