11

Underscore in URL gets escaped to %5F and does not work.

I'm trying to use an underscore in a link in my answers at stackoverlow. However, the link does not work in the resulting HTML.

This is similar to the discussion here. But the answers doesn't work for me. Specifically, I use the provided editor to create the link which should work according this answer.

Is there a way to avoid the escaping?

The link works in Internet Explorer but not in Firefox. So it might be a Firefox bug. But strangely the link works with Firefox from the editors preview!?

1
  • 1
    It seems that nowadays the underscore is no longer escaped to be %5F. That is good, as Firefox treats an escaped underscore differently than Chrome, which might mess up when the server is not configured correctly. Like try http://pear.php.net/package/XML%5FSerializer in both browsers. In Firefox note the URL in the 404 message (and the encoded GET in its request), while the URL loads just fine in Chrome.
    – Arjan
    Dec 24, 2011 at 12:02

4 Answers 4

2

What should I tell the kind folks at sqlite.org to fix their webserver to deal with this issue?

When I link to this page (http://www.sqlite.org/lang%5Fupdate.html) I get the following:

Document Not Found

The document /lang_5Fupdate.html is not avaivable on this server

I would call this a fringe issue, except that sqlite.org is a reputable, well-known site.

1
  • Apparently, somewhere in the past 2 years, they did change (or: fix?) the server configuration. (The current Firefox still asks for document/lang_%5Fupdate.html, but today that is handled fine by that server. Chrome asks for the URL with a real underscore even when using the encoded URL, and hence has no issues no matter how the server is configured.)
    – Arjan
    Dec 24, 2011 at 14:36
2

A fix for this would be good - I want to link to some github repositories from careers. However, the URLs have underscores, and github.com doesn't handle this issue either, so I have no way of linking to that work from my careers page.

Anyone clicking on the link ends up with a 404 page - not cool. I want to show off my awesomeness, but markdown is mocking me!

I realize that it's technically legal to escape underscores, but it's not mandatory.

From http://www.ietf.org/rfc/rfc2396.txt

2.3. Unreserved Characters

   Data characters that are allowed in a URI but do not have a reserved
   purpose are called unreserved.  These include upper and lower case
   letters, decimal digits, and a limited set of punctuation marks and
   symbols.

      unreserved  = alphanum | mark

      mark        = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"

   Unreserved characters can be escaped without changing the semantics
   of the URI, but this should not be done unless the URI is being used
   in a context that does not allow the unescaped character to appear.
1
  • And Wikipedia, emphasis mine: URIs that differ only by whether an unreserved character is percent-encoded or appears literally are equivalent by definition, but URI processors, in practice, may not always recognize this equivalence. For example, URI consumers shouldn't treat "%41" differently from "A" or "%7E" differently from "~", but some do. For maximum interoperability, URI producers are discouraged from percent-encoding unreserved characters.
    – Arjan
    Dec 24, 2011 at 11:31
1

Bottom line, the destination webserver is configured incorrectly, because %5F and _ are equivalent.

We had a lot of issues with underscores in URLs causing markdown problems (among other unusual characters), so we auto-escape them.

4
  • 1
    I've the destination server is the problem, why does it work from IE 8 and in the preview?
    – wierob
    Aug 21, 2009 at 10:12
  • Maybe you can resolve those markdown problems differently. Try: code.google.com/apis/ajax/playground/… vs code.google.com/apis/ajax/playground/…
    – dlamblin
    Nov 12, 2009 at 18:58
  • Correct, the target webserver should handle this, but we don't always have control over it.
    – madlep
    Nov 13, 2009 at 11:56
  • 1
    Automatically change all URLs to bit.ly URLs and you wouldn't have this problem Dec 28, 2009 at 15:40
1

I have the exact same issue on SO. Unfortunately we do not always have the power to reconfigure the destination webserver. I work around it by manually putting anchor hrefs in the editor, but I occasionally forget and end up with a broken link. Then I have to go back and edit my answer to fix the link.

Please consider coming up with a resolution for this issue.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .