Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purl can fail to parse the fragment #66

Open
arnaud-lb opened this issue Jun 11, 2018 · 3 comments
Open

Purl can fail to parse the fragment #66

arnaud-lb opened this issue Jun 11, 2018 · 3 comments

Comments

@arnaud-lb
Copy link
Contributor

Purl tries to parse fragments, but does not check for errors. When it happens, the fragment is completely missing from the stringified URL:

$url = new Url('http://example.com/#hello:123');
echo (string) $url, "\n";

This script outputs this:

http://example.com/

The problem is that in Fragment.php, $this->data is merged with the result of parse_url($this->fragment). If parse_url returns false, array_merge returns null, and $this->data is null:

$this->data = array_merge($this->data, parse_url($this->fragment));

@arnaud-lb
Copy link
Contributor Author

Here is a fix that worked for me: arnaud-lb@67a6f61

@jwage
Copy link
Owner

jwage commented Jun 11, 2018

Hi, Thanks for creating the issue and investigating the problem. Could you send a pull request for this change?

peter279k added a commit to peter279k/purl that referenced this issue Jun 24, 2018
peter279k added a commit to peter279k/purl that referenced this issue Jun 24, 2018
@jwage
Copy link
Owner

jwage commented Apr 11, 2019

I tried this fix but it doesn't seem to work. I am not sure how to fix this at the moment.

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

No branches or pull requests

2 participants