joepie91 / python-whois

A python module for retrieving and parsing WHOIS data
Do What The F*ck You Want To Public License
398 stars 188 forks source link

Different behavior between pwhois and pwhois -f for .ch TLDs #43

Open pe opened 10 years ago

pe commented 10 years ago

pwhois swisscom.ch does not parse the name servers:


Registrant
    Name              : Karin Hug
                        Domain Registration
    Organization      : Swisscom AG
    Street address    : alte Tiefenaustrasse 6
    Postal code       : CH-3050
    City              : Bern
    Country           : Switzerland

Technical Contact
    Name              : Andreas Disteli
    Organization      : Swisscom IT Services AG
    Street address    : Ostermundigenstrasse 99 6
    Postal code       : CH-3050
    City              : Bern
    Country           : Switzerland

But saving it to file and parsing it from there works (pwhois --raw swisscom.ch > swisscom.ch && pwhois -f swisscom.ch .):

Name server       : dns1.swisscom.com
Name server       : dns2.swisscom.com
Name server       : dns3.swisscom.com
Name server       : dns6.swisscom.ch
Name server       : dns7.swisscom.ch

Registrant
    Name              : Karin Hug
                        Domain Registration
    Organization      : Swisscom AG
    Street address    : alte Tiefenaustrasse 6
    Postal code       : CH-3050
    City              : Bern
    Country           : Switzerland

Technical Contact
    Name              : Andreas Disteli
    Organization      : Swisscom IT Services AG
    Street address    : Ostermundigenstrasse 99 6
    Postal code       : CH-3050
    City              : Bern
    Country           : Switzerland
joepie91 commented 9 years ago

Well, that was a rather bizarre issue, but it should be fixed with this patch. Turns out that saving to a file and then re-reading it would make it lose the second trailing newline, leading to the nameserver block regex not picking it up anymore (as it expects two newlines to signify the end of the block). I've changed the regex to also see end-of-string as a valid block terminator, so that should be fixed now.

I'll be awaiting some feedback on other issues / pull requests until tomorrow, and if nothing else happens to be merged in, I'll be releasing a new version. I'll also have to look into why the tests missed this - they should've caught the absence of nameservers, and I'm not sure why they didn't.