Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7129

Re: Validating string for FDQN

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!news.ecp.fr!feeder2.cambriumusenet.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'something,': 0.07; 'hostname': 0.09; 'subject:string': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'defined': 0.14; 'library': 0.15; 'angelico': 0.16; 'domain.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'qualified.': 0.16; 'syntactic': 0.16; 'tld.': 0.16; 'url:tld': 0.16; 'whois': 0.16; 'tue,': 0.17; 'url:code': 0.17; 'header:In-Reply-To:1': 0.21; 'assume': 0.23; 'received:209.85.210.174': 0.23; 'received:mail- iy0-f174.google.com': 0.23; "doesn't": 0.25; 'recognized': 0.26; 'string': 0.26; 'script': 0.27; "i'm": 0.27; 'message- id:@mail.gmail.com': 0.28; 'characters,': 0.30; 'to:addr:python- list': 0.33; 'list': 0.33; "isn't": 0.33; 'chris': 0.34; 'there': 0.35; 'weird': 0.35; 'test': 0.35; 'determine': 0.36; 'probably': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.37; 'partial': 0.37; 'hello,': 0.38; 'domain': 0.38; 'url:org': 0.38; 'eric': 0.38; 'too,': 0.38; 'subject:: ': 0.38; 'url:google': 0.38; 'received:209': 0.39; 'add': 0.39; 'to:addr:python.org': 0.39; 'simply': 0.60; 'here:': 0.62; 'url:p': 0.63
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=aDzJSfBlRrT4geplAWMgm8vpmdpNMs0aUUCBKtXN2Fg=; b=RhbLxx3Zq4pSbwrInls0yBG1Q+9nRc6SsCDibPgK/McPG2TC+Yl4R0Av7N0UeoPumt 7CVRdXhDfcIfwNOqxUQDJpJ8N+77XkM1NrK3RiWcE2oUVJqzgY/RiEnWGCCHmuzEkyOZ 06Vuj2N+tLVNWF9CT0lauXcVWgYdDuZF+dugU=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=HQOH5s9rSKMyPbvG8fHWSJNEFImVufN14J5EjESjqB7IHHh9apHXD3ushePcsUxqq4 E6KzB0/P8ARFFTxP37oI05v8oSPtEurct1KlNpo4S4RXbMv6e4GettWRGCc8s4lZgpto UflQoZqNfQaB/ywutPWNYssdvKKXFnfGgcVAw=
MIME-Version 1.0
In-Reply-To <d30814aa-494f-457f-8a56-5ebe802f4725@z7g2000prh.googlegroups.com>
References <d30814aa-494f-457f-8a56-5ebe802f4725@z7g2000prh.googlegroups.com>
Date Tue, 7 Jun 2011 12:50:22 +1000
Subject Re: Validating string for FDQN
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2516.1307415025.9059.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 82.94.164.166
X-Trace 1307415026 news.xs4all.nl 49177 [::ffff:82.94.164.166]:44080
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7129

Show key headers only | View raw


On Tue, Jun 7, 2011 at 10:40 AM, Eric <eric.wong.t@gmail.com> wrote:
> Hello,
>
> Is there a library or regex that can determine if a string is a fqdn
> (fully qualified domain name)? I'm writing a script that needs to add
> a defined domain to the end of a hostname if it isn't already a fqdn
> and doesn't contain the defined domain.

One reliable way to test would be to do a whois check on the name. If
it comes up with something, it's fully qualified.

http://code.google.com/p/pywhois/

Alternatively, if all you want is a simple syntactic check, and if you
can assume that the name is already a valid domain name (no weird
characters, etc), then you can simply divide it on the last dot and
see if the last part is a recognized TLD. A partial list of TLDs can
be found here:

http://data.iana.org/TLD/tlds-alpha-by-domain.txt

There are other TLDs too, including .localhost and .test, which you
can probably ignore.

Chris Angelico

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Validating string for FDQN Eric <eric.wong.t@gmail.com> - 2011-06-06 17:40 -0700
  Re: Validating string for FDQN harrismh777 <harrismh777@charter.net> - 2011-06-06 20:55 -0500
  Re: Validating string for FDQN Chris Angelico <rosuav@gmail.com> - 2011-06-07 12:50 +1000
  Re: Validating string for FDQN Philip Semanchuk <philip@semanchuk.com> - 2011-06-06 23:10 -0400
  Re: Validating string for FDQN Nobody <nobody@nowhere.com> - 2011-06-07 06:23 +0100
    Re: Validating string for FDQN Chris Angelico <rosuav@gmail.com> - 2011-06-07 15:52 +1000
      Re: Validating string for FDQN Chris Torek <nospam@torek.net> - 2011-06-07 06:20 +0000
      Re: Validating string for FDQN Nobody <nobody@nowhere.com> - 2011-06-07 21:46 +0100

csiph-web