14

I initially edited this question because of what I thought was a dead link. But I realize now that it's not the problem, and the problem remains:

  • If I click the link on SO, I get a "Page not found error" in the Stanford server.
  • If I refresh the page, there is still the error.
  • If I click in the URL bar and press enter, the page loads.

The problem happens at least with Firefox on Windows.

Apparently, the problem is the link reads %7E instead of ~, and somehow the character isn't properly translated.

Funnily, while editing the question, this URL (with tilde) worked: URL. But now that the question is posted, it doesn't.

Is this a problem with the web browser, with SO, or with the Stanford server?

13
  • 5
  • @SebastianSimon Oh, so it's actually markdown! It makes sense. Thanks! So, the solution is writing a html 'a' tag instead? It's extraordinary that in more than 9 years on Math.SE, I didn't notice this problem. Or maybe it's rather new and appeared with an update of markdown?
    – user13963867
    Commented Jan 31, 2022 at 17:49
  • 3
    @Jean-ClaudeArbaut well, it's not exactly common to have tilde in URLs, but with the advent of the :~:text syntax (scroll to text fragment), the usage increased dramatically, and the issue that's always been present surfaced :) It's no surprise you haven't encountered the behavior until now.
    – 0Valt
    Commented Jan 31, 2022 at 19:09
  • 5
    @OlegValter Actually, it's quite common to find a tilde in URLs of university pages: the pattern is usually "server/~user/...", exactly like for this case.
    – user13963867
    Commented Jan 31, 2022 at 21:01
  • 2
    @Jean-ClaudeArbaut sure, I did not mean they used to be very uncommon (however, where I live, university sites do not follow this convention [?]), just that the scroll to text feature brought the issue into the spotlight. Hopefully SE gets to addressing the issue in reasonable time
    – 0Valt
    Commented Jan 31, 2022 at 21:30
  • What do you mean by "type enter"? "type it and press Enter"? Or something else? Commented Feb 1, 2022 at 13:00
  • @PeterMortensen Yes, press enter. I mean, if you click on the link, you get an error, and if you click to refresh, same error. However, if you click the URL as if you were to edit it (but don't change anything), then press enter, you get the page. I guess the web browser does the translation %7E -> tilde.
    – user13963867
    Commented Feb 1, 2022 at 13:04
  • 1
    A particular corner of Stack Overflow (especially problems installing "wheels" on Windows) uses such a page a lot - https://www.lfd.uci.edu/~gohlke/pythonlibs. Sample. Commented Feb 1, 2022 at 13:20
  • cont' - The error message contains "is not a supported wheel on this platform" and some of the questions may have some of the highest view rates among the 22,184,115 questions. Sample 2. Sample 3 (low scored and probably a duplicate). Commented Feb 1, 2022 at 13:29
  • In that MSE post example there is a text fragment and a tilde in that text fragment. But that is not the case in the example here(?). Is the problem independent of text fragments? Why do the three examples (same site, but with and without text fragment URLs) I provided seem to work fine? (Not rhetorical questions.) Commented Feb 1, 2022 at 13:43
  • 1
    @PeterMortensen there is a permanent redirect on the site you provided, you make the request to the url https://www.lfd.uci.edu/%7Egohlke/pythonlibs but then are redirected to https://www.lfd.uci.edu/~gohlke/pythonlibs/ with a 301. Commented Feb 1, 2022 at 13:57
  • Here is one containing "~" which results in the browser prompting with a save file dialog (the first link)... Commented Nov 8, 2022 at 20:43
  • @PeterMortensen I'm not sure about this one: there is no such file at pages.cs.wisc.edu/%7ebeechung/ref. I'm not 100% sure, but I think Apache is smart enough to pick gcc-intro.html.bak instead, and it's downloaded because it has extension .bak.
    – user13963867
    Commented Nov 9, 2022 at 0:45

1 Answer 1

4

It seems like the stanford.edu servers do not decode the hex in that URI before they check with the username, they do decode it later, you can see the headers. They could be using a CDN that decodes the URI and sends those headers, but they themselves may not decode it.

According to the URI specification (RFC3986) Section 2.1:

2.1.  Percent-Encoding

   A percent-encoding mechanism is used to represent a data octet in a
   component when that octet's corresponding character is outside the
   allowed set or is being used as a delimiter of, or within, the
   component.  A percent-encoded octet is encoded as a character
   triplet, consisting of the percent character "%" followed by the two
   hexadecimal digits representing that octet's numeric value.  For
   example, "%20" is the percent-encoding for the binary octet
   "00100000" (ABNF: %x20), which in US-ASCII corresponds to the space
   character (SP).  Section 2.4 describes when percent-encoding and
   decoding is applied.

      pct-encoded = "%" HEXDIG HEXDIG

   The uppercase hexadecimal digits 'A' through 'F' are equivalent to
   the lowercase digits 'a' through 'f', respectively.  If two URIs
   differ only in the case of hexadecimal digits used in percent-encoded
   octets, they are equivalent.  For consistency, URI producers and
   normalizers should use uppercase hexadecimal digits for all percent-
   encodings.

and Section 2.4:

   For example, the octet
   corresponding to the tilde ("~") character is often encoded as "%7E"
   by older URI processing implementations; the "%7E" can be replaced by
   "~" without changing its interpretation.
  1. The URL containing %7E at the start does not seem to be invalid.
  2. It seems too common that ~ is encoded as %7E.

Since stanford.edu's Server: header says that they are using Apache: mod_userdir in Apache seems to run before the URI is decoded. I have tested this, and this doesn't happen with the latest version.

Apart from that, the URL seems to be encoded by markdown (as mentioned in the comments).

For me, it only happens with Firefox, not with Chrome.

This seems to have happened with many posts, as seen with this SEDE query: https://data.stackexchange.com/stackoverflow/revision/1551278/1896569/ Also, it does not seem to have affected every website, as many websites do seem to work with that encoded URL.


I found where to report this first of all: https://www.stanford.edu/site/accessibility/, although I would suggest being calm, and not reporting continuously and overwhelming those people.

You must log in to answer this question.