From 5d32a3c88341d89fd3752f496f23cbe6664e6f5c Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Fri, 23 May 2014 18:02:10 +0200 Subject: [PATCH] Fix Nominet parsing for registrants that do not have a state/region listed --- pythonwhois/parse.py | 2 +- test/data/direct.gov.uk | 51 ++++++++++++++++++++++++++++ test/target_default/direct.gov.uk | 1 + test/target_normalized/direct.gov.uk | 1 + 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 test/data/direct.gov.uk create mode 100644 test/target_default/direct.gov.uk create mode 100644 test/target_normalized/direct.gov.uk diff --git a/pythonwhois/parse.py b/pythonwhois/parse.py index 80302c1..5560285 100644 --- a/pythonwhois/parse.py +++ b/pythonwhois/parse.py @@ -519,7 +519,7 @@ def parse_registrants(data): "Eligibility Type:[ ]*Citizen\/Resident\n[\s\S]*Registrant Contact ID:[ ]*(?P.+)\n[\s\S]*Registrant Contact Name:[ ]*(?P.+)\n", # .au individual "Registrant:[ ]*(?P.+)\n[\s\S]*Eligibility Type:[ ]*(Higher Education Institution|Company|Incorporated Association|Other)\n[\s\S]*Registrant Contact ID:[ ]*(?P.+)\n[\s\S]*Registrant Contact Name:[ ]*(?P.+)\n", # .au educational, company, 'incorporated association' (non-profit?), other (spotted for linux.conf.au, unsure if also for others) " Registrant:\n (?P.+)\n\n Registrant type:\n .*\n\n Registrant's address:\n The registrant .* opted to have", # Nominet (.uk) with hidden address - " Registrant:\n (?P.+)\n\n[\s\S]* Registrant type:\n .*\n\n Registrant's address:\n (?P.+)\n(?: (?P.+)\n)?(?: (?P.+)\n)? (?P.+)\n (?P.+)\n (?P.+)\n (?P.+)\n\n", # Nominet (.uk) with visible address + " Registrant:\n (?P.+)\n\n[\s\S]* Registrant type:\n .*\n\n Registrant's address:\n (?P.+)\n(?: (?P.+)\n(?: (?P.+)\n)??)?? (?P[^0-9\n]+)\n(?: (?P.+)\n)? (?P.+)\n (?P.+)\n\n", # Nominet (.uk) with visible address "Domain Owner:\n\t(?P.+)\n\n[\s\S]*?(?:Registrant Contact:\n\t(?P.+))?\n\nRegistrant(?:'s)? (?:a|A)ddress:(?:\n\t(?P.+)\n(?:\t(?P.+)\n)?(?:\t(?P.+)\n)?\t(?P.+)\n\t(?P.+))?\n\t(?P.+)(?:\n\t(?P.+) \(Phone\)\n\t(?P.+) \(FAX\)\n\t(?P.+))?\n\n", # .ac.uk - what a mess... "Registrant contact:\n (?P.+)\n (?P.*)\n (?P.+), (?P.+) (?P.+) (?P.+)\n\n", # Fabulous.com "registrant-name:\s*(?P.+)\nregistrant-type:\s*(?P.+)\nregistrant-address:\s*(?P.+)\nregistrant-postcode:\s*(?P.+)\nregistrant-city:\s*(?P.+)\nregistrant-country:\s*(?P.+)\n(?:registrant-phone:\s*(?P.+)\n)?(?:registrant-email:\s*(?P.+)\n)?", # Hetzner diff --git a/test/data/direct.gov.uk b/test/data/direct.gov.uk new file mode 100644 index 0000000..9579189 --- /dev/null +++ b/test/data/direct.gov.uk @@ -0,0 +1,51 @@ + Domain name: + gov.uk + + Registrant: + UK Cabinet Office + + Registrant type: + UK Government Body + + Registrant's address: + Government Digital Service + Aviation House, 6th floor + 125 Kingsway + London + OX11 OSG + GB + + Registrar: + No registrar listed. This domain is directly registered with Nominet. + + Relevant dates: + Registered on: before Aug-1996 + Registration status: + No registration status listed. + + Name servers: + ns0.ja.net. + ns2.ja.net. + ns3.ja.net. + ns4.ja.net. + auth50.ns.de.uu.net. + auth00.ns.de.uu.net. + ns1.surfnet.nl. + + + WHOIS lookup made at 16:56:04 23-May-2014 + +-- +This WHOIS information is provided for free by Nominet UK the central registry +for .uk domain names. This information and the .uk WHOIS are: + + Copyright Nominet UK 1996 - 2014. + +You may not access the .uk WHOIS or use any data from it except as permitted +by the terms of use available in full at http://www.nominet.org.uk/whoisterms, +which includes restrictions on: (A) use of the data for advertising, or its +repackaging, recompilation, redistribution or reuse (B) obscuring, removing +or hiding any or all of this notice and (C) exceeding query rate or volume +limits. The data is provided on an 'as-is' basis and may lag behind the +register. Access may be withdrawn or restricted at any time. + diff --git a/test/target_default/direct.gov.uk b/test/target_default/direct.gov.uk new file mode 100644 index 0000000..045d5a1 --- /dev/null +++ b/test/target_default/direct.gov.uk @@ -0,0 +1 @@ +{"nameservers": ["auth50.ns.de.uu.net", "auth00.ns.de.uu.net", "ns0.ja.net", "ns2.ja.net", "ns3.ja.net", "ns4.ja.net", "ns1.surfnet.nl"], "status": ["No registration status listed."], "contacts": {"admin": null, "tech": null, "registrant": {"city": "London", "name": "UK Cabinet Office", "street": "Government Digital Service\nAviation House, 6th floor\n125 Kingsway", "country": "GB", "postalcode": "OX11 OSG"}, "billing": null}, "registrar": ["No registrar listed. This domain is directly registered with Nominet."], "raw": [" Domain name:\n gov.uk\n\n Registrant:\n UK Cabinet Office\n\n Registrant type:\n UK Government Body\n\n Registrant's address:\n Government Digital Service\n Aviation House, 6th floor\n 125 Kingsway\n London\n OX11 OSG\n GB\n\n Registrar:\n No registrar listed. This domain is directly registered with Nominet.\n\n Relevant dates:\n Registered on: before Aug-1996\n Registration status:\n No registration status listed.\n\n Name servers:\n ns0.ja.net. \n ns2.ja.net. \n ns3.ja.net. \n ns4.ja.net. \n auth50.ns.de.uu.net. \n auth00.ns.de.uu.net. \n ns1.surfnet.nl. \n\n\n WHOIS lookup made at 16:56:04 23-May-2014\n\n-- \nThis WHOIS information is provided for free by Nominet UK the central registry\nfor .uk domain names. This information and the .uk WHOIS are:\n\n Copyright Nominet UK 1996 - 2014.\n\nYou may not access the .uk WHOIS or use any data from it except as permitted\nby the terms of use available in full at http://www.nominet.org.uk/whoisterms,\nwhich includes restrictions on: (A) use of the data for advertising, or its\nrepackaging, recompilation, redistribution or reuse (B) obscuring, removing\nor hiding any or all of this notice and (C) exceeding query rate or volume\nlimits. The data is provided on an 'as-is' basis and may lag behind the\nregister. Access may be withdrawn or restricted at any time. \n\n"]} \ No newline at end of file diff --git a/test/target_normalized/direct.gov.uk b/test/target_normalized/direct.gov.uk new file mode 100644 index 0000000..045d5a1 --- /dev/null +++ b/test/target_normalized/direct.gov.uk @@ -0,0 +1 @@ +{"nameservers": ["auth50.ns.de.uu.net", "auth00.ns.de.uu.net", "ns0.ja.net", "ns2.ja.net", "ns3.ja.net", "ns4.ja.net", "ns1.surfnet.nl"], "status": ["No registration status listed."], "contacts": {"admin": null, "tech": null, "registrant": {"city": "London", "name": "UK Cabinet Office", "street": "Government Digital Service\nAviation House, 6th floor\n125 Kingsway", "country": "GB", "postalcode": "OX11 OSG"}, "billing": null}, "registrar": ["No registrar listed. This domain is directly registered with Nominet."], "raw": [" Domain name:\n gov.uk\n\n Registrant:\n UK Cabinet Office\n\n Registrant type:\n UK Government Body\n\n Registrant's address:\n Government Digital Service\n Aviation House, 6th floor\n 125 Kingsway\n London\n OX11 OSG\n GB\n\n Registrar:\n No registrar listed. This domain is directly registered with Nominet.\n\n Relevant dates:\n Registered on: before Aug-1996\n Registration status:\n No registration status listed.\n\n Name servers:\n ns0.ja.net. \n ns2.ja.net. \n ns3.ja.net. \n ns4.ja.net. \n auth50.ns.de.uu.net. \n auth00.ns.de.uu.net. \n ns1.surfnet.nl. \n\n\n WHOIS lookup made at 16:56:04 23-May-2014\n\n-- \nThis WHOIS information is provided for free by Nominet UK the central registry\nfor .uk domain names. This information and the .uk WHOIS are:\n\n Copyright Nominet UK 1996 - 2014.\n\nYou may not access the .uk WHOIS or use any data from it except as permitted\nby the terms of use available in full at http://www.nominet.org.uk/whoisterms,\nwhich includes restrictions on: (A) use of the data for advertising, or its\nrepackaging, recompilation, redistribution or reuse (B) obscuring, removing\nor hiding any or all of this notice and (C) exceeding query rate or volume\nlimits. The data is provided on an 'as-is' basis and may lag behind the\nregister. Access may be withdrawn or restricted at any time. \n\n"]} \ No newline at end of file