We have moved to a new Sailfish OS Forum. Please start new discussions there.
0

Protocol ambiguity in browser links "~/" leads to "~/~/" or /home/nemo/~/

asked 2015-01-17 18:42:14 +0300

rdmo gravatar image

updated 2015-04-23 11:02:12 +0300

tldr; "Some addressing standards are meant to be unbroken."

"No they're not."

To use a specific directory in an HTML document, use<base href="PATH_TO_PARENT_DIRECTORY/"> (see developer.mozilla.org/.../base. The tilde does not resolve in the browser to $HOME, only in some shells.


Original post:

A link in a local plaintext file is <a href="~/todo">~/todo</a>.

As a recovering konqueror user, I thought it would lead to file:///home/nemo/todo.

Instead, it tries to show file:///home/nemo/~/todo, which does not exist.

Please consider making the browser's treatment of $HOME, or~/ like bash and enable bookmarks to show and handle links like ~/path/to/file and not only /home/nemo/path/to/file. It would helpful to not have to prefix with /home/nemo/. The regular expressions: /^~\// or /^~/.

Interpreting the tilde at the beginning of a location or in href or src attributes could make bookmarks easier to manage on mobile device-sized screens, in a similar way to how /^./ and /^../ let users avoid writing or reading the whole path to the working directory and its parent. If files get moved around more than a little this can be quite important.

In this narrow use case I think this would work.

edit retag flag offensive close delete

Comments

1

What's that with attaching mysterious unrelared screenshots to all your posts? It makes it very hard to read them.

pichlo ( 2015-01-18 13:02:12 +0300 )edit

Since in-browser text copy and paste are how they are right now, it was easier to take the screenshot. The page was http://en.m.wikipedia.org/wiki/URL_normalization and the shot section talked about the tilde. I gather that this looks less useful outside a small screen. On my phone it looks fine.

rdmo ( 2015-01-18 13:38:34 +0300 )edit

1 Answer

Sort by » oldest newest most voted
7

answered 2015-01-17 23:06:58 +0300

Okw gravatar image

I certainly do not expect href="~/todo" to take me to file:///home/nemo/todo.

Tilde for $HOME is a shell expansion. Browser isn't a shell. As a matter of fact tilde is a valid URI character. Hence it would violate the protocol if given some special treatment.

edit flag offensive delete publish link more

Comments

@rdmo: Konqueror is a file manager that also happens to be a browser, that's the only reason it even resolves ~ that way. I'm even surprised this browser doesn't just look up the tilde in the selected search engine. Why do you want this browser to behave like a file manager when it clearly isn't one?

nthn ( 2015-01-18 11:46:17 +0300 )edit

@rdmo, I'm going to stick with the phrasing I chose. I might take "certainly" out if my morning coffee turns out to be a success. I admit that I maybe got a little carried away, but it often happens when someone suggests to break protocols. Sorry about that. Wasn't meant to be offensive or personal in any way.

What you're suggesting, or actually reporting as a bug, is an obvious violation to the protocol. Browsers aren't supposed to treat ~ in any other special way than sometimes decode/encode it as %7E. A shell is designed to replace ~ with $HOME. A browser is not.

Imagine this. I'll give you the following URL: http://domain.com/~rdmo/, which is a common user directory notation on many web servers. Would you expect it to take you to http://domain.com/file:///home/nemordmo/? Atleast I wouldn't.

Okw ( 2015-01-18 11:58:22 +0300 )edit

I hope your coffee turned out to be a good one, and thanks for taking the time to elaborate on protocol. I looked at a few RFCs and the article by an author in academia on tilde *nix history, and I'll edit my question to become more specific. The only places I'd hope to see ~ interpreted as $HOME would be for addresses beginning ~/.

rdmo ( 2015-01-18 12:52:50 +0300 )edit

@nthn: I'd like to be able to do more things in bash or the native browser. That is why I'm keen for the browser to be able to handle local Save as on contenteditable markup.

rdmo ( 2015-01-18 13:06:56 +0300 )edit
1

Konqueror is by no means the only browser that resolves ~ to a user's home directory. For example, in both Chrome and Chromium, if I type "~" into the address bar, it opens file:///home/keithzg, and Chrome is certainly not a combined file+web browser like Konqueror.

keithzg ( 2015-01-21 00:56:41 +0300 )edit
Login/Signup to Answer

Question tools

Follow
1 follower

Stats

Asked: 2015-01-17 18:42:14 +0300

Seen: 420 times

Last updated: Apr 23 '15