FFFF Treat empty ports consistently in _uric_escape, as_iri and URI.pm bracket fix-up · Issue #211 · libwww-perl/URI · GitHub
[go: up one dir, main page]

Skip to content

Treat empty ports consistently in _uric_escape, as_iri and URI.pm bracket fix-up #211

Open

Description

@oalders

The fix for empty ports in host() (s/:\d+$// → s/:\d*$// in URI::_server::host) left the old pattern in three other places that split a port off the authority:

  • lib/URI/_server.pm:17, in _uric_escape: $host =~ s/(:\d+)\z//
  • lib/URI/_server.pm:44, in as_iri: $host =~ s/(:\d+)\z//
  • lib/URI.pm:134, in the %5B/%5D fix-up: $host =~ s/(:\d+)$//

With an empty port (http://münchen.de:/), none of these matches, so the bare : stays attached to $host. It then goes into IDNA encode/decode or the bracket un-escaping with the colon on the end.

Nothing visibly breaks today. http://münchen.de:/ still becomes http://xn--mnchen-bma9c.de:/, as_iri round-trips it, and host returns xn--mnchen-bma9c.de. The IDNA code happens to tolerate the trailing colon, and the bracket fix-up only touches %5B/%5D.

Suggested change: switch these to :\d* so every place that splits off a port treats an empty port the same way as host(), _port and host_port. Add a test with an IDN host and an empty port (http://münchen.de:/) to cover _uric_escape and as_iri.

Low priority: this is about keeping the code consistent, not a bug anyone can hit.

🤖 Generated with Claude Code · Opus 5.5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      0