3 comments

  • f311a3 minutes ago
    Unfortunately, simple URL parsing breaks on so many things. There is a reason on why every URL parsing library is at least a few thousand LOCs.<p>One common way to test it is just to pass ipv6 url.
  • Retr0id8 minutes ago
    &gt; LineReader splits input into lines, handles \n and \r\n, and trims the stray trailing \r that malformed input likes to leave behind<p>Is there a common source of extra \r in malformed inputs, beyond those existing as part of \r\n? Or is this just a dig at Windows-style line endings? If there&#x27;s something weird going on I think I&#x27;d rather fail loudly.<p>&gt; Bounding the inner scanner to a single line makes “run past the end of a malformed line” unrepresentable rather than merely unlikely.<p>I don&#x27;t really see what makes it &quot;unrepresentable&quot;, and this reads more like &quot;if you used the right scanning logic, you can&#x27;t have used the wrong scanning logic&quot;.
    • inigyou2 minutes ago
      Sure, start with \r\n, split on \n, now you have a stray \r at the end of every input.
      • Retr0id1 minute ago
        But the preceding clause says it handles \r\n. If you&#x27;re already handling \r\n, what remaining sources of \r are there, that you&#x27;d actually want to silently ignore?
  • mrkeen22 minutes ago
    If you draw a line from &#x27;ad-hoc byte-wrangling nonsense&#x27; to &#x27;parser combinators&#x27;, this can&#x27;t be more than 20% along it.<p>Looking at the linked URL parser, why <i>doesn&#x27;t</i> it look like<p><pre><code> url = do scheme authority path query fragment where scheme = ... authority = ... etc. </code></pre> It looks totally ad-hoc.