Skip to content

$uri->path_segments improperly escaping URLs #159

@coffinsfcompute

Description

@coffinsfcompute
#!/usr/bin/perl

use strict;
use warnings;

use URI;
use URI::Escape;

my $uri = URI->new('http://example.com/abdefghijklmnopqrstuvwxyzABDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~%3A%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D');
print("$uri\n");
$uri->path_segments($uri->path_segments);
print("$uri\n");

$uri->path_segments($uri->path_segments); should be a no-op, but it instead corrupts the URL encoding. I noticed this as it changed an encoded + in a URL to a literal + which represents a space in HTTP and therefore it fetched the wrong URL from a server. I'm pretty sure the fix for this is easy (replace the custom escaping in path_segments with a call to URI::Escape->uri_escape), and I may submit a follow up PR for this, but I wanted first confirm that this is considered an issue before I made a PR as I only have a few hours of experience with Perl and only noticed this issue trying to debug an existing code base.

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