Skip Menu |

This queue is for tickets about the Regexp-Common CPAN distribution.

Report information
The Basics
Id: 23626
Status: resolved
Priority: 0/
Queue: Regexp-Common

People
Owner: Nobody in particular
Requestors: FANY [...] cpan.org
Cc: 248075 [...] rt.noris.net
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 2.120
Fixed in: (no value)



CC: 248075 [...] rt.noris.net
Subject: matching of hostnames with labels beginning with digits
Currently there seems to be no way to match hostnames like 01051.com with $RE{net}{domain}. I'm aware that these hostnames are not valid according to RFC 1035. They do exist, however... 01051.com. 1D IN A 213.203.202.103 01051.com. 1D IN MX 10 mail.wxx.com. 01051.com. 1D IN NS ns1.internetnamen.de. 01051.com. 1D IN NS ns2.internetnamen.de. 01051.com. 1D IN SOA ns1.internetnamen.de. [...] ... so (probably not only) I have to deal with them. So I'd suggest adding an option to allow such labels, e.g. {-startwithdigit} (see patch attached). Regards, fany
Subject: Regexp-Common-startwithdigit.patch
--- Regexp-Common-2.120/lib/Regexp/Common/net.pm 2004-12-29 00:31:54.000000000 +0100 +++ Regexp-Common-2.121/lib/Regexp/Common/net.pm 2006-02-16 11:46:46.000000000 +0100 @@ -69,8 +69,9 @@ my $let_dig_hyp = "[-A-Za-z0-9]"; # Domain names, from RFC 1035. -pattern name => [qw (net domain -nospace=)], +pattern name => [qw (net domain -nospace= -startwithdigit=)], create => sub { + my $letter = defined $_[1]{-startwithdigit} ? $letter : $let_dig; if (exists $_ [1] {-nospace} && !defined $_ [1] {-nospace}) { return "(?k:$letter(?:(?:$let_dig_hyp){0,61}$let_dig)?" . "(?:\\.$letter(?:(?:$let_dig_hyp){0,61}$let_dig)?)*)" --- Regexp-Common-2.120/t/test_domain.t 2003-07-05 01:09:36.000000000 +0200 +++ Regexp-Common-2.121/t/test_domain.t 2006-02-16 11:45:34.000000000 +0100 @@ -76,3 +76,25 @@ fail 'host. .example.com'; fail 'host .example.com'; fail 'ho st.example.com'; + +try $RE{net}{domain}{-startwithdigit}; + +pass 'host.example.com'; +pass 'a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z'; +pass 'A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z'; +pass 'host1.example.com'; +pass 'host-1.example.com'; +pass 'host'; +pass 'a-----------------1.example.com'; +pass 'a123456a.example.com'; +pass 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789.com'; +pass ' '; +pass '123host.example.com'; +pass 'www.01051.com'; +fail 'host-.example.com'; +fail 'host.example.com.'; +fail 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789a.com'; +fail ' '; +fail 'host. .example.com'; +fail 'host .example.com'; +fail 'ho st.example.com';
Subject: $RE{net}{domain} uses obsolete definition of domain names
The definition of a domain name used in Regexp::Common::net is from RFFC1035, back when domain parts were not allowed to begin with digits. This has since been changed (RFC 1101, April 1989; see also www.3com.com). Now, since the docs say that Regexp::Common::net do actually state that it uses the RFC1035 definition, this isn't strictly a bug, though it is heavily suboptimal. The fix is either to point out in the docs that the RFC1035 definition of a domain name is obsolete and therefore that $RE{net}{domain} is almost certainly Not What You Want, or to fix the regexp, as follows: --- net.pm.orig Sun Nov 26 15:53:58 2006 +++ net.pm Sun Nov 26 15:54:15 2006 @@ -72,12 +72,12 @@ pattern name => [qw (net domain -nospace=)], create => sub { if (exists $_ [1] {-nospace} && !defined $_ [1] {-nospace}) { - return "(?k:$letter(?:(?:$let_dig_hyp){0,61}$let_dig)?" . - "(?:\\.$letter(?:(?:$let_dig_hyp){0,61}$let_dig)?)*)" + return "(?k:$let_dig(?:(?:$let_dig_hyp){0,61}$let_dig)?" . + "(?:\\.$let_dig(?:(?:$let_dig_hyp){0,61}$let_dig)?)*)" } else { - return "(?k: |(?:$letter(?:(?:$let_dig_hyp){0,61}$let_dig)?" . - "(?:\\.$letter(?:(?:$let_dig_hyp){0,61}$let_dig)?)*))" + return "(?k: |(?:$let_dig(?:(?:$let_dig_hyp){0,61}$let_dig)?" . + "(?:\\.$let_dig(?:(?:$let_dig_hyp){0,61}$let_dig)?)*))" } }, ;
So this bug report has been open for three years and a trivial, working patch attached for just as long. Is there any reason not to merge it?
This has been fixed in version 2013031201.