This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 12 - Pages: 1 - Last Post: 10 Jan 19, 17:34 Last Post By: JeffTucker
JeffTucker

Posts: 8,039
Registered: 31-Jan-2006
URL-encode links?
Posted: 7 Jul 12, 00:23
 
  Click to reply to this thread Reply
I was fidding with a switch from HTML 4.01 Strict to HTML5, and one of the things HTML5 insists upon is that links be URL-encoded. Got me thinking... would there ever be a situation in which a user would not want links to be URL-encoded? In other words, why is this even an option in jAlbum? (It's under Album > Settings > Advanced > Naming.)
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: URL-encode links?
Posted: 7 Jul 12, 03:45   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
We should probably switch the default to url encode links. The reason it's off by default has been IE. With IE (don't know exactly what versions), album previews break if you have foreign characters in file names and use URL encoding. I don't want the first experience people have with jAlbum to be a broken preview. Perhaps IE9 is doing better. I haven't tested, but if it does, then it's probably time to change the default to have URL encoding on by default.
JeffTucker

Posts: 8,039
Registered: 31-Jan-2006
Re: URL-encode links?
Posted: 7 Jul 12, 03:47   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
I'll do some testing and get back to you. I've got native IE9 and IE8 to test with. Earlier versions of IE are really no longer an issue. (Hell, the next version of jQuery won't be supporting IE8!)
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: URL-encode links?
Posted: 7 Jul 12, 03:55   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Thanks for testing
JeffTucker

Posts: 8,039
Registered: 31-Jan-2006
Re: URL-encode links?
Posted: 7 Jul 12, 03:58   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Yup, both IE8 and IE9 choke horribly in local preview when given file names with diacritical marks in their names, and URL-encoding turned on. :(

No problem once the album is viewed from a server.
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: URL-encode links?
Posted: 7 Jul 12, 04:04   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Too bad. I guess IE9 still has a fair market share. One workaround could be to launch the preview via jAlbum's embedded web server, but then I guess we will have problems with local firewalls blocking it... There is obviously no end to what misery IE has caused to the web.
Dschuwi

Posts: 296
Registered: 12-Nov-2003
Re: URL-encode links?
Posted: 10 Jul 12, 15:47   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
That's the reason why I still force CA2 to use one-byte encoding. To bad, and it's always and still Internet Explorer :-(
JeffTucker

Posts: 8,039
Registered: 31-Jan-2006
Re: URL-encode links?
Posted: 9 Jan 19, 19:44   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
We should probably switch the default to url encode links. The reason it's off by default has been IE.

Yup, that was the only reason to allow a user to turn it off.

In jAlbum 17.2, this option is no longer there - links are automatically URL-encoded. In the intervening years, there have been several dozen "problem" reports in which turning URL-encoding on was the quick fix to the problem, so this change was long overdue. :)

Skin developers still need to pay attention to links that users are entering in skin variable fields, however. For example, if your skin lets a user create a button with a link to some other site, and gives him a place to enter the URL, the jAlbum core knows nothing about this, and can't do the encoding if it's needed. The skin needs to take care of it.
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: URL-encode links?
Posted: 10 Jan 19, 12:11   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Yes, now URLs are always encoded. I had to keep the engine.setUrlEncode() setter method though in order to not break skins that calls this directly (Tiger does), but it's being ignored.
JeffTucker

Posts: 8,039
Registered: 31-Jan-2006
Re: URL-encode links?
Posted: 10 Jan 19, 13:07   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
Yes, now URLs are always encoded. I had to keep the engine.setUrlEncode() setter method though in order to not break skins that calls this directly (Tiger does), but it's being ignored.

Pffft. Just tell that lazy-ass developer to update his skin. ;)

Is there a reliable way to determine whether a user-entered URL has been encoded already? I'm thinking that if the string contains a "%" sign, that's almost surely a sign that it has been encoded. It's hard to imagine a URL that would contain that character otherwise.
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: URL-encode links?
Posted: 10 Jan 19, 13:19   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
jGromit wrote:
davidekholm wrote:
Yes, now URLs are always encoded. I had to keep the engine.setUrlEncode() setter method though in order to not break skins that calls this directly (Tiger does), but it's being ignored.

Pffft. Just tell that lazy-ass developer to update his skin. ;)

Is there a reliable way to determine whether a user-entered URL has been encoded already? I'm thinking that if the string contains a "%" sign, that's almost surely a sign that it has been encoded. It's hard to imagine a URL that would contain that character otherwise.


I'm not sure. Detecting a percentage should be one way to know unless the URL actually contains a literal %. Finding a space or 8-bit character would be one way to know it's not URL encoded. That's what I would look for.
JeffTucker

Posts: 8,039
Registered: 31-Jan-2006
Re: URL-encode links?
Posted: 10 Jan 19, 13:32   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
But a bunch of the characters that need to be encoded, like &, aren't 8-bit, so it would be quite a messy search, wouldn't it? You'd have to look for the presence of any of the low-order reserved characters, or anything over decimal 127.

In my skins, I'm assuming that a user-entered URL has not been encoded, but I give the user a way to turn off the encoding, if he's doing that beforehand. But copying and pasting from the browser's address bar, for example, generates encoded strings (at least in some browsers - I haven't tested it), so a user may not even understand that he's providing encoded URL's. And the skin setting is "all or nothing," i.e., it applies encoding to all user-entered URL's, or to none of them.

And then there are query strings, in which you don't want to encode a lot of things, like "=".

I'm tempted to roll the dice and assume that no unencoded URL would ever contain a % sign. That might be "close enough." Or maybe a % sign followed by 0-9: all encoded characters follow that pattern.
JeffTucker

Posts: 8,039
Registered: 31-Jan-2006
Re: URL-encode links?
Posted: 10 Jan 19, 17:34   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
jGromit wrote:
Or maybe a % sign followed by 0-9: all encoded characters follow that pattern.

Not true, alas - diacriticals get encoded as strings like %C3%A4, which is รค.

And % isn't a reserved character, so it's legal to use one in a directory name. So, if you see this:
http://example.com/no%20space/index.html
The directory name might be no space or it might really be no%20space. You can't tell.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums