<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>24289</bug_id>
          
          <creation_ts>2014-01-14 07:25:32 +0000</creation_ts>
          <short_desc>DNS length limits check</short_desc>
          <delta_ts>2014-01-14 11:45:20 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>URL</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Santiago M. Mola">santi</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>mike</cc>
          
          <qa_contact>sideshowbarker+urlspec</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>98403</commentid>
    <comment_count>0</comment_count>
    <who name="Santiago M. Mola">santi</who>
    <bug_when>2014-01-14 07:25:32 +0000</bug_when>
    <thetext>Relevant RFC: http://www.ietf.org/rfc/rfc1035.txt

--
Domain names in messages are expressed in terms of a sequence of labels.
Each label is represented as a one octet length field followed by that
number of octets.  Since every domain name ends with the null label of
the root, a domain name is terminated by a length byte of zero.  The
high order two bits of every length octet must be zero, and the
remaining six bits of the length field limit the label to 63 octets or
less.

To simplify implementations, the total length of a domain name (i.e.,
label octets and label length octets) is restricted to 255 octets or
less.
--

- Maximum label length is 63 bytes.
- Although I couldn&apos;t find it in the standard, in practice, implementations require a minimum label length of 1 byte except for the root label.
- Maximum length in the textual representation (without final dot) is 253.
- Maximum number of labels is 127 (not counting root label). This is just a consequence of the other limits.

I couldn&apos;t find any check for this during URL parsing except for Mozilla, which checks for the 63 byte length limit for labels. This seems for practical purposes (limiting buffer lengths and so on).

See http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/nsIDNService.cpp:

--
static const uint32_t kMaxDNSNodeLen = 63;

[...]

   if (in.Length() &gt; kMaxDNSNodeLen) {
     NS_WARNING(&quot;IDN node too large&quot;);
     return NS_ERROR_FAILURE;
   }
--

Note that, despite the warning text, it is done also for ASCII-only hosts.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98409</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-01-14 10:42:57 +0000</bug_when>
    <thetext>See step 8 of http://tools.ietf.org/html/rfc3490#section-4.1 which is required by URL.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98418</commentid>
    <comment_count>2</comment_count>
    <who name="Santiago M. Mola">santi</who>
    <bug_when>2014-01-14 11:21:47 +0000</bug_when>
    <thetext>Alright. I missed it. So no checks for number of labels / total length?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98419</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-01-14 11:45:20 +0000</bug_when>
    <thetext>In Live DOM Viewer:

&lt;a href=&quot;http://0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789/&quot;&gt;test&lt;/a&gt;
&lt;script&gt;w(document.querySelector(&quot;a&quot;).host.length)&lt;/script&gt;

Seems this check is not implemented in either Chrome or Firefox. I can also get hosts longer than 300 code points. I think for now I&apos;ll just let this slide as &quot;not my problem&quot;...</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>