metaregistrar / php-epp-client

Object-oriented PHP EPP Client
https://www.metaregistrar.com/docs/
MIT License
214 stars 160 forks source link

Empty contact handles on .fi domain info response causes exception #46

Closed aksl closed 8 years ago

aksl commented 8 years ago

It is possible to receive empty contact handles for .fi domains on info domain request resulting in an exception in eppContactHandle.

Details:

This is a slightly obfuscated response from the testing environment:

<?xml version="1.0" encoding="utf-8"?>
<epp xmlns:host="urn:ietf:params:xml:ns:host-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xmlns:obj="urn:ietf:params:xml:ns:obj-1.0" xmlns="urn:ietf:params:xml:ns:epp-1.0">
  <response>
    <result code="1000">
      <msg>Command completed successfully</msg>
    </result>
    <resData>
      <domain:infData>
        <domain:name>DOMAIN_NAME</domain:name>
        <domain:registrylock>0</domain:registrylock>
        <domain:autorenew>0</domain:autorenew>
        <domain:status s="Granted"></domain:status>
        <domain:registrant>CXXXXX</domain:registrant>
        <domain:contact type="admin"></domain:contact>
        <domain:contact type="billing"></domain:contact>
        <domain:contact type="tech">CXXXXX</domain:contact>
        <domain:ns>
          <domain:hostObj>NAMESERVER1</domain:hostObj>
          <domain:hostObj>NAMESERVER2</domain:hostObj>
        </domain:ns>
        <domain:clID>CXXXX</domain:clID>
        <domain:crID>CXXXX</domain:crID>
        <domain:crDate>2016-07-13T20:59:52.097</domain:crDate>
        <domain:exDate>2017-07-13T20:59:52.02</domain:exDate>
        <domain:authInfo></domain:authInfo>
      </domain:infData>
    </resData>
    <trID>
      <svTRID>1234567</svTRID>
    </trID>
  </response>
</epp>

As you can see, it is possible for admin and billing contacts to be present, but empty. This happens when there is no assigned contact to those roles.

The end result is eppInfoDomainResponse->getDomainContacts() leading into an exception, as empty handle gets passed to eppContactHandle which triggers an exception in setContactHandle() (Contact handle specified is not valid: ).

Proposed fix: check if $contact->nodeValue has length in eppInfoDomainResponse->getDomainContacts() before creating a eppContactHandle and adding it to list of contacts present.

metaregistrar commented 8 years ago

I have fixed your problem in the latest dev branch. The empty contacts do not create a contact object right now.