Zend Framework

Zend_Filter::isHostname not allow a hostname that has one character part like "d.hatena.ne.jp" (TRAC-130)

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.1.3
  • Fix Version/s: 0.8.0
  • Component/s: Zend_Validate
  • Labels:
    None

Description

Zend_Filter::isHostname returns false,
When it called with a hostname that has one character part.
ex) "d.hatena.ne.jp", "a.hatena.ne.jp"

The reason is following regular expression code.

// check input against domain name schema

  • $status = @preg_match('/^(?:[^\W_](?:[^\W_]|-){0,61}[^\W_]\.)+[a-zA-Z]{2,6}\.?$/', $value);

    I changed like this, that returns true by calling with a hostname with one character part.

    // check input against domain name schema
    + $status = @preg_match('/^(?:[^\W_]((?:[^\W_]|-){0,61}[^\W_])?\.)+[a-zA-Z]{2,6}\.?$/', $value);

But I don't know it's valid for RFCs about URI.
I think this fix is not so good.

Issue Links

Activity

Hide
Mark Evans added a comment -

I have been looking for the RFC which specifies the hostname requirements and cannot find any restriction on the number of characters as part of a domain name, does anyone know if there is a restriction or can this fixed be applied?

Show
Mark Evans added a comment - I have been looking for the RFC which specifies the hostname requirements and cannot find any restriction on the number of characters as part of a domain name, does anyone know if there is a restriction or can this fixed be applied?
Hide
Kevin Golding added a comment -

Well according to RFC2181:

The DNS itself places only one restriction on the particular labels
that can be used to identify resource records. That one restriction
relates to the length of the label and the full name. The length of
any one label is limited to between 1 and 63 octets. A full domain
name is limited to 255 octets (including the separators).

Based on that logic the fix looks valid.

Show
Kevin Golding added a comment - Well according to RFC2181:
The DNS itself places only one restriction on the particular labels that can be used to identify resource records. That one restriction relates to the length of the label and the full name. The length of any one label is limited to between 1 and 63 octets. A full domain name is limited to 255 octets (including the separators).
Based on that logic the fix looks valid.
Hide
Cameron Brunner added a comment -

This is bothering me as well, I cant use Zend_Feed due to it using the hostname validation from this. Are there any plans to impliment this patch? This patch seems to fix the problems i have as well.

Show
Cameron Brunner added a comment - This is bothering me as well, I cant use Zend_Feed due to it using the hostname validation from this. Are there any plans to impliment this patch? This patch seems to fix the problems i have as well.
Hide
Bill Karwin added a comment -

Changing fix version to 0.9.0.

Show
Bill Karwin added a comment - Changing fix version to 0.9.0.
Hide
Gavin added a comment -

I won't promise this issue is fixed by the patch I committed, but it is an improvement.
Unless I hear otherwise from the community, I consider this issue "resolved" for the moment.

Show
Gavin added a comment - I won't promise this issue is fixed by the patch I committed, but it is an improvement. Unless I hear otherwise from the community, I consider this issue "resolved" for the moment.
Hide
Darby Felton added a comment -

Please provide unit tests to at least indicate the effects of the change.

Also, please replace tab characters for indent with 4 spaces, per the coding standards.

Show
Darby Felton added a comment - Please provide unit tests to at least indicate the effects of the change. Also, please replace tab characters for indent with 4 spaces, per the coding standards.
Hide
Chris Shiflett added a comment -

The isHostname() implementation needs to be rewritten, in my opinion. If someone could write a good test suite, I'd be happy to have a look at it.

Show
Chris Shiflett added a comment - The isHostname() implementation needs to be rewritten, in my opinion. If someone could write a good test suite, I'd be happy to have a look at it.
Hide
Gregory Szorc added a comment -

moving to Zend_Validate component b/c Zend_Filter static methods are deprecated as of 0.8.0.

Show
Gregory Szorc added a comment - moving to Zend_Validate component b/c Zend_Filter static methods are deprecated as of 0.8.0.
Hide
Simon R Jones added a comment -

Fixed with revision 3429, d.hatena.ne.jp has been added in the unit test and it passes validation.

Show
Simon R Jones added a comment - Fixed with revision 3429, d.hatena.ne.jp has been added in the unit test and it passes validation.
Hide
Wil Sinclair added a comment -

Bookkeeping. Closing old issues and assigning them to the person who ultimately resolved the issue.

Show
Wil Sinclair added a comment - Bookkeeping. Closing old issues and assigning them to the person who ultimately resolved the issue.

People

Vote (2)
Watch (4)

Dates

  • Created:
    Updated:
    Resolved: