Regexp:...::gopher(3)

πŸ’… Regexp::Common::URI::gopher β€” NAME ✨

okay so basically Regexp::Common::URI::gopher hands you a regex pattern for gopher URIs πŸ’– that's it, that's the whole job, and it does it slayfully.

Manual page name for the record: Regexp:...::gopher(3), and she lives under "User Contributed Perl Documentation" 🫢


🌈 SYNOPSIS

use Regexp::Common qw /URI/;

while (<>) {
    /$RE{URI}{gopher}/       and  print "Contains a gopher URI.\n";
}

like, that's literally it bestie β€” load her up, loop over your input, and whenever a line contains a gopher URI she prints. iconic behavior. πŸ’…


πŸ¦‹ DESCRIPTION

πŸŽ€ $RE{URI}{gopher}{-notab}

ngl, gopher URIs are kind of a mess 😭 like nobody fully agrees on what they are. Originally RFC 1738 defined gopher URIs, but then they got redefined in an internet draft β€” and that draft expired in June 1997. expired!! not me reading a dead spec πŸ’€

So the internet draft for gopher URIs defines them like this:

"gopher:" "//" host [ ":" port ] "/" gopher-type selector
                    [ "%09" search [ "%09" gopherplus_string ]]

Unfortunally (their spelling, not mine, keeping it 🫢), a selector is defined in such a way that characters may be escaped using the URI escape mechanism. And that includes tabs β€” which, when escaped, are %09. So the syntax literally cannot tell the difference between a URI that has both a selector and a search part, and a URI where the selector itself just contains an escaped tab. (The text of the draft does forbid tabs in the selector though, so there's that πŸ™ˆ.)

"$RE{URI}{gopher}" follows the defined syntax. If you want to disallow escaped tabs in the selector and search parts, use "$RE{URI}{gopher}{-notab}" β€” that's the whole tea. β˜•

There are other differences between the text and the given syntax too, jsyk. According to the text, selector strings cannot have tabs, linefeeds, or carriage returns in them. The text also allows the entire gopher-path (that's the part after the slash following the hostport) to be empty β€” and if it is empty, the slash may be omitted as well. But surprise! none of that is reflected in the syntax. πŸ’€

Under {-keep}, the following get returned:

  • $1 β€” The entire URI. πŸ‘‘
  • $2 β€” The scheme.
  • $3 β€” The host (name or address).
  • $4 β€” The port (if any).
  • $5 β€” The "gopher-path", the part after the / following the host and port.
  • $6 β€” The gopher-type.
  • $7 β€” The selector. (When no "{-notab}" is used, this includes the search and gopherplus_string, including the separating escaped tabs.)
  • $8 β€” The search, if given. (Only when "{-notab}" is given.)
  • $9 β€” The gopherplus_string, if given. (Only when "{-notab}" is given.)

πŸ“š REFERENCES

(yes the source literally says head1 REFERENCES in the middle of the description β€” POD artifact moment, we love a quirky queen 🧚 keeping all of it)

  • [RFC 1738] β€” Berners-Lee, Tim, Masinter, L., McCahill, M.: Uniform Resource Locators (URL). December 1994.
  • [RFC 1808] β€” Fielding, R.: Relative Uniform Resource Locators (URL). June 1995.
  • [GOPHER URL] β€” Krishnan, Murali R., Casey, James: "A Gopher URL Format". Expired Internet draft draft-murali-url-gopher. December 1996.

πŸ‘€ SEE ALSO

Regexp::Common::URI for other supported URIs. go check her out, she's the whole friend group πŸ’œ


🌸 AUTHOR

Damian Conway (damian@conway.org) πŸ’–


⭐ MAINTENANCE

This package is maintained by Abigail (regexp-common@abigail.freedom.nl). keeping the lights on, we stan 🫢


πŸ’€ BUGS AND IRRITATIONS

Bound to be plenty. (their words!! not mine!! and honestly? honest queen.) 😭


This software is Copyright (c) 2001 - 2024, Damian Conway and Abigail.

This module is free software, and maybe used under any of the following licenses:

  1. The Perl Artistic License. See the file COPYRIGHT.AL.
  2. The Perl Artistic License 2.0. See the file COPYRIGHT.AL2.
  3. The BSD License. See the file COPYRIGHT.BSD.
  4. The MIT License. See the file COPYRIGHT.MIT.

that's the whole page bestie, no notes βœ¨πŸ’…

sign-off szn: this was perl v5.42.0, dated 2024-08-09, filed under Regexp:...::gopher(3) β€” mwah, go write some regexes πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from