Skip to content

fix path merge with path object #2245

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sparrow2009
Copy link

Mojo::Path's support of merging objects of class Mojo::Path (vs. strings) until now is implemented by object stringification followed by a reparsing using a default Mojo::Path object.

This approach works fine for merged objects with a character set of UTF-8 as this is also the default character set for Mojo::Path objects. It can fail however for other character sets.

Instead copy the path parts and the slash attributes from the source to the target object.

The missing tests for merging objects are included using the ISO-8859-15 character set. That way those tests can also function as regression tests. The ISO-8859-15 character set deviates from ISO-8859-1 and in turn from Unicode in that it reassigns code points of less common symbols (code point A4 which is the currency sign in ISO-8859-1/Unicode is replaced by the Euro currency sign e.g.).

Background:
Mojo::URL::to_abs() e.g. passes path objects to Mojo::Path::merge() in order to merge the path onto the base path today. And can fail in the way outlined above if the path object is not configured to be UTF-8.

Mojo::Path's support of merging objects of class Mojo::Path (vs. strings)
until now is implemented by object stringification followed by a reparsing
using a default Mojo::Path object.

This approach works fine for merged objects with a character set of UTF-8 as
this is also the default character set for Mojo::Path objects. It can fail
however for other character sets.

Instead copy the path parts and the slash attributes from the source to
the target object.

The missing tests for merging objects are included using the ISO-8859-15
character set. That way those tests can also function as regression tests.
The ISO-8859-15 character set deviates from ISO-8859-1 and in turn from
Unicode in that it reassigns code points of less common symbols (code
point A4 which is the currency sign in ISO-8859-1/Unicode is replaced
by the Euro currency sign e.g.).

Background:
Mojo::URL::to_abs() e.g. passes path objects to Mojo::Path::merge()
in order to merge the path onto the base path today. And can fail in the
way outlined above if the path object is not configured to be UTF-8.
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

Successfully merging this pull request may close these issues.

1 participant