php-whois
php-whois copied to clipboard
Fix TypeError in BlockParser::parseDate with fallback regex
Fixes #220
| Q | A |
|---|---|
| Branch? | master |
| Bug fix? | yes |
| New feature? | no |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #220 |
| License | MIT |
The issue is that sometimes the WHOIS output contains the same key multiple times in places where it's not expected.
One particular domain name I had this issue with had WHOIS output looking like this:
Registrant Name: John Doe
Registrant Organization: n/a
Registrant Street: Example Street 420
Registrant Street: Apt. 42
Registrant Street:
Registrant City: Testertown
The ParserHelper::linesToGroups function turns this structure into something like this (formatted as YAML here):
Registrant Name: John Doe
Registrant Organization: n/a
Registrant Street:
- Example Street 420
- Apt. 42
- ""
Registrant City: Testertown
Turning duplicate keys into an array is more or less expected, because duplicate keys are common and sometimes different, and then all values are relevant (i.e. the Name Server key).
The date parser assumes that all keys it gets are single keys, but that's not the case here, and that's what causes it to break.