From a86d44dfdc8a179f53aa8494f885eb694302d882 Mon Sep 17 00:00:00 2001 From: Christian Koepp Date: Tue, 18 Feb 2014 17:10:32 +0100 Subject: [PATCH] added RFC3490 feature (decoded unicode domains) --- pythonwhois/net.py | 9 ++- test/data/alliancefrançaise.nu | 33 ++++++++++ test/data/bäckerei.de | 67 +++++++++++++++++++++ test/target_default/alliancefrançaise.nu | 1 + test/target_default/bäckerei.de | 1 + test/target_normalized/alliancefrançaise.nu | 1 + test/target_normalized/bäckerei.de | 1 + 7 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 test/data/alliancefrançaise.nu create mode 100644 test/data/bäckerei.de create mode 100644 test/target_default/alliancefrançaise.nu create mode 100644 test/target_default/bäckerei.de create mode 100644 test/target_normalized/alliancefrançaise.nu create mode 100644 test/target_normalized/bäckerei.de diff --git a/pythonwhois/net.py b/pythonwhois/net.py index d33945e..ed7251e 100644 --- a/pythonwhois/net.py +++ b/pythonwhois/net.py @@ -1,7 +1,12 @@ import socket, re +from codecs import encode, decode from . import shared -def get_whois_raw(domain, server="", previous=[]): +def get_whois_raw(domain, server="", previous=[], rfc3490=True): + + if rfc3490: + domain = encode( domain if type(domain) is unicode else decode(domain, "utf8"), "idna" ) + if len(previous) == 0: # Root query target_server = get_root_server(domain) @@ -10,7 +15,7 @@ def get_whois_raw(domain, server="", previous=[]): if domain.endswith(".jp") and target_server == "whois.jprs.jp": request_domain = "%s/e" % domain # Suppress Japanese output elif domain.endswith(".de") and ( target_server == "whois.denic.de" or target_server == "de.whois-servers.net" ): - request_domain = "-T dn,ace -C US-ASCII %s" % domain # regional specific stuff + request_domain = "-T dn,ace %s" % domain # regional specific stuff elif target_server == "whois.verisign-grs.com": request_domain = "=%s" % domain # Avoid partial matches else: diff --git a/test/data/alliancefrançaise.nu b/test/data/alliancefrançaise.nu new file mode 100644 index 0000000..b88f365 --- /dev/null +++ b/test/data/alliancefrançaise.nu @@ -0,0 +1,33 @@ +# Copyright (c) 1997- .SE (The Internet Infrastructure Foundation). +# All rights reserved. + +# The information obtained through searches, or otherwise, is protected +# by the Swedish Copyright Act (1960:729) and international conventions. +# It is also subject to database protection according to the Swedish +# Copyright Act. + +# Any use of this material to target advertising or +# similar activities is forbidden and will be prosecuted. +# If any of the information below is transferred to a third +# party, it must be done in its entirety. This server must +# not be used as a backend for a search engine. + +# Result of search for registered domain names under +# the .nu top level domain. +# The data is in the UTF-8 character set and the result is +# printed with eight bits. +state: active +domain: xn--alliancefranaise-npb.nu (alliancefrançaise.nu) +holder: qi9c3zbvhr +admin-c: qi9c3zbvhr +tech-c: qi9c3zbvhr +billing-c: qi9c3zbvhr +created: 2010-03-02 +modified: 2014-01-24 +expires: 2021-06-02 +nserver: ns01.hostcontrol.com +nserver: ns02.hostcontrol.com +dnssec: unsigned delegation +status: ok +registrar: Worldnames, Inc. + diff --git a/test/data/bäckerei.de b/test/data/bäckerei.de new file mode 100644 index 0000000..9a81feb --- /dev/null +++ b/test/data/bäckerei.de @@ -0,0 +1,67 @@ +% Copyright (c) 2010 by DENIC +% Version: 2.0 +% +% Restricted rights. +% +% Terms and Conditions of Use +% +% The data in this record is provided by DENIC for informational purposes only. +% DENIC does not guarantee its accuracy and cannot, under any circumstances, +% be held liable in case the stored information would prove to be wrong, +% incomplete or not accurate in any sense. +% +% All the domain data that is visible in the whois service is protected by law. +% It is not permitted to use it for any purpose other than technical or +% administrative requirements associated with the operation of the Internet. +% It is explicitly forbidden to extract, copy and/or use or re-utilise in any +% form and by any means (electronically or not) the whole or a quantitatively +% or qualitatively substantial part of the contents of the whois database +% without prior and explicit written permission by DENIC. +% It is prohibited, in particular, to use it for transmission of unsolicited +% and/or commercial and/or advertising by phone, fax, e-mail or for any similar +% purposes. +% +% By maintaining the connection you assure that you have a legitimate interest +% in the data and that you will only use it for the stated purposes. You are +% aware that DENIC maintains the right to initiate legal proceedings against +% you in the event of any breach of this assurance and to bar you from using +% its whois service. +% +% The DENIC whois service on port 43 never discloses any information concerning +% the domain holder/administrative contact. Information concerning the domain +% holder/administrative contact can be obtained through use of our web-based +% whois service available at the DENIC website: +% http://www.denic.de/en/domains/whois-service/web-whois.html +% + +Domain: bäckerei.de +Domain-Ace: xn--bckerei-5wa.de +Nserver: ns1.parkingcrew.net +Nserver: ns2.parkingcrew.net +Status: connect +Changed: 2013-04-03T00:14:26+02:00 + +[Tech-C] +Type: PERSON +Name: Mechelke Jens +Address: Heidberger Strasse 1a +PostalCode: 28865 +City: Lilienthal +CountryCode: DE +Phone: +49.4298939487 +Fax: +49.4298939488 +Email: jens@mechelke.de +Changed: 2008-05-27T16:56:58+02:00 + +[Zone-C] +Type: PERSON +Name: Mechelke Jens +Address: Heidberger Strasse 1a +PostalCode: 28865 +City: Lilienthal +CountryCode: DE +Phone: +49.4298939487 +Fax: +49.4298939488 +Email: jens@mechelke.de +Changed: 2008-05-27T16:56:58+02:00 + diff --git a/test/target_default/alliancefrançaise.nu b/test/target_default/alliancefrançaise.nu new file mode 100644 index 0000000..2e7869e --- /dev/null +++ b/test/target_default/alliancefrançaise.nu @@ -0,0 +1 @@ +{"status": ["active", "ok"], "updated_date": ["2014-01-24T00:00:00"], "contacts": {"admin": {"handle": "qi9c3zbvhr"}, "tech": {"handle": "qi9c3zbvhr"}, "registrant": {"handle": "qi9c3zbvhr"}, "billing": {"handle": "qi9c3zbvhr"}}, "nameservers": ["ns01.hostcontrol.com", "ns02.hostcontrol.com"], "expiration_date": ["2021-06-02T00:00:00"], "creation_date": ["2010-03-02T00:00:00"], "raw": ["# Copyright (c) 1997- .SE (The Internet Infrastructure Foundation). \n# All rights reserved. \n\n# The information obtained through searches, or otherwise, is protected \n# by the Swedish Copyright Act (1960:729) and international conventions. \n# It is also subject to database protection according to the Swedish \n# Copyright Act. \n\n# Any use of this material to target advertising or \n# similar activities is forbidden and will be prosecuted. \n# If any of the information below is transferred to a third \n# party, it must be done in its entirety. This server must \n# not be used as a backend for a search engine. \n\n# Result of search for registered domain names under \n# the .nu top level domain. \n# The data is in the UTF-8 character set and the result is \n# printed with eight bits.\nstate: active\ndomain: xn--alliancefranaise-npb.nu (alliancefran\u00e7aise.nu)\nholder: qi9c3zbvhr\nadmin-c: qi9c3zbvhr\ntech-c: qi9c3zbvhr\nbilling-c: qi9c3zbvhr\ncreated: 2010-03-02\nmodified: 2014-01-24\nexpires: 2021-06-02\nnserver: ns01.hostcontrol.com\nnserver: ns02.hostcontrol.com\ndnssec: unsigned delegation\nstatus: ok\nregistrar: Worldnames, Inc.\n\n"], "registrar": ["Worldnames, Inc."]} \ No newline at end of file diff --git a/test/target_default/bäckerei.de b/test/target_default/bäckerei.de new file mode 100644 index 0000000..706962a --- /dev/null +++ b/test/target_default/bäckerei.de @@ -0,0 +1 @@ +{"status": ["connect"], "updated_date": ["2013-04-03T00:14:26", "2008-05-27T16:56:58"], "contacts": {"admin": null, "tech": null, "registrant": null, "billing": null}, "nameservers": ["ns1.parkingcrew.net", "ns2.parkingcrew.net"], "raw": ["% Copyright (c) 2010 by DENIC\n% Version: 2.0\n% \n% Restricted rights.\n% \n% Terms and Conditions of Use\n% \n% The data in this record is provided by DENIC for informational purposes only.\n% DENIC does not guarantee its accuracy and cannot, under any circumstances,\n% be held liable in case the stored information would prove to be wrong,\n% incomplete or not accurate in any sense.\n% \n% All the domain data that is visible in the whois service is protected by law.\n% It is not permitted to use it for any purpose other than technical or\n% administrative requirements associated with the operation of the Internet.\n% It is explicitly forbidden to extract, copy and/or use or re-utilise in any\n% form and by any means (electronically or not) the whole or a quantitatively\n% or qualitatively substantial part of the contents of the whois database\n% without prior and explicit written permission by DENIC.\n% It is prohibited, in particular, to use it for transmission of unsolicited\n% and/or commercial and/or advertising by phone, fax, e-mail or for any similar\n% purposes.\n% \n% By maintaining the connection you assure that you have a legitimate interest\n% in the data and that you will only use it for the stated purposes. You are\n% aware that DENIC maintains the right to initiate legal proceedings against\n% you in the event of any breach of this assurance and to bar you from using\n% its whois service.\n% \n% The DENIC whois service on port 43 never discloses any information concerning\n% the domain holder/administrative contact. Information concerning the domain\n% holder/administrative contact can be obtained through use of our web-based\n% whois service available at the DENIC website:\n% http://www.denic.de/en/domains/whois-service/web-whois.html\n% \n\nDomain: b\u00e4ckerei.de\nDomain-Ace: xn--bckerei-5wa.de\nNserver: ns1.parkingcrew.net\nNserver: ns2.parkingcrew.net\nStatus: connect\nChanged: 2013-04-03T00:14:26+02:00\n\n[Tech-C]\nType: PERSON\nName: Mechelke Jens\nAddress: Heidberger Strasse 1a\nPostalCode: 28865\nCity: Lilienthal\nCountryCode: DE\nPhone: +49.4298939487\nFax: +49.4298939488\nEmail: jens@mechelke.de\nChanged: 2008-05-27T16:56:58+02:00\n\n[Zone-C]\nType: PERSON\nName: Mechelke Jens\nAddress: Heidberger Strasse 1a\nPostalCode: 28865\nCity: Lilienthal\nCountryCode: DE\nPhone: +49.4298939487\nFax: +49.4298939488\nEmail: jens@mechelke.de\nChanged: 2008-05-27T16:56:58+02:00\n\n"], "emails": ["jens@mechelke.de"]} \ No newline at end of file diff --git a/test/target_normalized/alliancefrançaise.nu b/test/target_normalized/alliancefrançaise.nu new file mode 100644 index 0000000..c88d6cd --- /dev/null +++ b/test/target_normalized/alliancefrançaise.nu @@ -0,0 +1 @@ +{"status": ["Active", "ok"], "updated_date": ["2014-01-24T00:00:00"], "contacts": {"admin": {"handle": "qi9c3zbvhr"}, "tech": {"handle": "qi9c3zbvhr"}, "registrant": {"handle": "qi9c3zbvhr"}, "billing": {"handle": "qi9c3zbvhr"}}, "nameservers": ["ns01.hostcontrol.com", "ns02.hostcontrol.com"], "expiration_date": ["2021-06-02T00:00:00"], "creation_date": ["2010-03-02T00:00:00"], "raw": ["# Copyright (c) 1997- .SE (The Internet Infrastructure Foundation). \n# All rights reserved. \n\n# The information obtained through searches, or otherwise, is protected \n# by the Swedish Copyright Act (1960:729) and international conventions. \n# It is also subject to database protection according to the Swedish \n# Copyright Act. \n\n# Any use of this material to target advertising or \n# similar activities is forbidden and will be prosecuted. \n# If any of the information below is transferred to a third \n# party, it must be done in its entirety. This server must \n# not be used as a backend for a search engine. \n\n# Result of search for registered domain names under \n# the .nu top level domain. \n# The data is in the UTF-8 character set and the result is \n# printed with eight bits.\nstate: active\ndomain: xn--alliancefranaise-npb.nu (alliancefran\u00e7aise.nu)\nholder: qi9c3zbvhr\nadmin-c: qi9c3zbvhr\ntech-c: qi9c3zbvhr\nbilling-c: qi9c3zbvhr\ncreated: 2010-03-02\nmodified: 2014-01-24\nexpires: 2021-06-02\nnserver: ns01.hostcontrol.com\nnserver: ns02.hostcontrol.com\ndnssec: unsigned delegation\nstatus: ok\nregistrar: Worldnames, Inc.\n\n"], "registrar": ["Worldnames, Inc."]} \ No newline at end of file diff --git a/test/target_normalized/bäckerei.de b/test/target_normalized/bäckerei.de new file mode 100644 index 0000000..d38e491 --- /dev/null +++ b/test/target_normalized/bäckerei.de @@ -0,0 +1 @@ +{"status": ["Connect"], "updated_date": ["2013-04-03T00:14:26", "2008-05-27T16:56:58"], "contacts": {"admin": null, "tech": null, "registrant": null, "billing": null}, "nameservers": ["ns1.parkingcrew.net", "ns2.parkingcrew.net"], "raw": ["% Copyright (c) 2010 by DENIC\n% Version: 2.0\n% \n% Restricted rights.\n% \n% Terms and Conditions of Use\n% \n% The data in this record is provided by DENIC for informational purposes only.\n% DENIC does not guarantee its accuracy and cannot, under any circumstances,\n% be held liable in case the stored information would prove to be wrong,\n% incomplete or not accurate in any sense.\n% \n% All the domain data that is visible in the whois service is protected by law.\n% It is not permitted to use it for any purpose other than technical or\n% administrative requirements associated with the operation of the Internet.\n% It is explicitly forbidden to extract, copy and/or use or re-utilise in any\n% form and by any means (electronically or not) the whole or a quantitatively\n% or qualitatively substantial part of the contents of the whois database\n% without prior and explicit written permission by DENIC.\n% It is prohibited, in particular, to use it for transmission of unsolicited\n% and/or commercial and/or advertising by phone, fax, e-mail or for any similar\n% purposes.\n% \n% By maintaining the connection you assure that you have a legitimate interest\n% in the data and that you will only use it for the stated purposes. You are\n% aware that DENIC maintains the right to initiate legal proceedings against\n% you in the event of any breach of this assurance and to bar you from using\n% its whois service.\n% \n% The DENIC whois service on port 43 never discloses any information concerning\n% the domain holder/administrative contact. Information concerning the domain\n% holder/administrative contact can be obtained through use of our web-based\n% whois service available at the DENIC website:\n% http://www.denic.de/en/domains/whois-service/web-whois.html\n% \n\nDomain: b\u00e4ckerei.de\nDomain-Ace: xn--bckerei-5wa.de\nNserver: ns1.parkingcrew.net\nNserver: ns2.parkingcrew.net\nStatus: connect\nChanged: 2013-04-03T00:14:26+02:00\n\n[Tech-C]\nType: PERSON\nName: Mechelke Jens\nAddress: Heidberger Strasse 1a\nPostalCode: 28865\nCity: Lilienthal\nCountryCode: DE\nPhone: +49.4298939487\nFax: +49.4298939488\nEmail: jens@mechelke.de\nChanged: 2008-05-27T16:56:58+02:00\n\n[Zone-C]\nType: PERSON\nName: Mechelke Jens\nAddress: Heidberger Strasse 1a\nPostalCode: 28865\nCity: Lilienthal\nCountryCode: DE\nPhone: +49.4298939487\nFax: +49.4298939488\nEmail: jens@mechelke.de\nChanged: 2008-05-27T16:56:58+02:00\n\n"], "emails": ["jens@mechelke.de"]} \ No newline at end of file