Skip to content

URLs with e.g. data: or mailto: scheme get /// injected #5459

@jrauh01

Description

@jrauh01

Describe the bug

If data:image/png is passed to Url::fromPath(), getAbsoluteUrl() returns data:///image/png.

To Reproduce

var_dump(Url::fromPath('data:image/png')->getAbsoluteUrl());

Problem

The scheme does automatically appended with ://. Additionally the base url, that is / is inserted.

Expected behavior

If data:image/png is passed to Url::fromPath(), getAbsoluteUrl() should return data:image/png instead of data:///image/png.

Additional context

Because ipl\Web\Widget\Link calls Url::fromPath() to create a URL object which calls $this->getAbsoulteUrl() in __toString() method, this causes problems e.g. when creating a download link. Browsers like chrome and firefox don't care about that, but safari does not trigger a download if the URL contains ///.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions