Commons Validator
  1. Commons Validator
  2. VALIDATOR-288

UrlValidator does not validate URL with simple domains (eg: http://hostname )

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.1 Release
    • Fix Version/s: 1.4.0 Release
    • Component/s: Routines
    • Labels:
      None

      Description

      A Url of the form "http://hostname" is not validated, when the hostname is simple, i.e does not have any dots.

      I think this is a valid URL and it should pass validation.

      The bug is in UrlValidator::isValidAuthority(), line 382

      String topLevel = domainSegment[segmentCount - 1];
      if (topLevel.length() < 2 || topLevel.length() > 4)

      { return false; }

      In this case, topLevel = "hostname"

        Activity

        Hide
        Jacob Zwiers added a comment -

        Patch which adds a test case (variation on VALIDATOR-248) to show this issue was addressed with the fix to that issue.

        Show
        Jacob Zwiers added a comment - Patch which adds a test case (variation on VALIDATOR-248 ) to show this issue was addressed with the fix to that issue.
        Hide
        Jacob Zwiers added a comment -

        As the test case shows, this can probably be considered a duplicate (or fixed indirectly by) VALIDATOR-248.

        Show
        Jacob Zwiers added a comment - As the test case shows, this can probably be considered a duplicate (or fixed indirectly by) VALIDATOR-248 .
        Hide
        Nick Burch added a comment -

        I've added a new option ALLOW_LOCAL_URLS in r1128396. With this set, http://localhost/ and http://machinename/ are accepted (the previous behaviour of them not being accepted remains if this isn't set)

        I've also added your test, with a few tweaks to use the option, thanks for that

        Show
        Nick Burch added a comment - I've added a new option ALLOW_LOCAL_URLS in r1128396. With this set, http://localhost/ and http://machinename/ are accepted (the previous behaviour of them not being accepted remains if this isn't set) I've also added your test, with a few tweaks to use the option, thanks for that

          People

          • Assignee:
            Unassigned
            Reporter:
            feroze daud
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development