Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the maximum length of a custom url protocol using synchronous pluggable protocols in internet explorer?

I'm running into a hard limit in Internet Explorer with application protocol's that exceed 508 characters in length. This limit is not enforced in other browsers, chrome etc...

The documentation on MSDN(1) does not seem to mention the maximum permissible length in the scheme-specific portion of the URI or total length including scheme.

508 characters is well below general limits for urls in IE reported to be 2083 characters (2).

Does anyone know if this is expected behavior, i'm using IE8, or perhaps I've got something wrong here?

References:

  • Asynchronous Pluggable Protocols

  • Maximum URL length is 2,083 characters in Internet Explorer

like image 273
Edward Wilde Avatar asked Jan 26 '12 11:01

Edward Wilde


2 Answers

I recently ran into this same problem and come up with the following solution. If you try to assign the URL directly like this:

 document.location.href = theUrlWithTheCustomProtocol;

you will run into this 508 character limit error and in IE8 you'll get a JavaScript error saying something about The "data area passed to a system call is too small."

To get around this problem, I switched from the above code to using JQuery to create an hidden iframe like this:

// Remove old frame
$('#hiddenIFrame').remove();

// Add new one
$('<iframe />', {
    'id': 'hiddenIFrame',
    'name': 'hiddenIFrame',
    'src': theUrlWithTheCustomProtocol,
    'style': 'display: none;'
}).appendTo("body");

This gets around the IE 508 character limit using document.location.href and this solution works for IE, FireFox, Chrome, and Safari.

like image 56
Michael Remijan Avatar answered Nov 15 '22 07:11

Michael Remijan


508 + some bookkeeping = 512 bytes

I think that the browser, after splitting off the protocol, stores it in a temporary buffer of a fixed size. Why, I don't know, and this seems like behaviour that might change in the future. Don't bank on it.

I'm also wondering why you'd need a protocol this long. Even a GUID is only 36 characters when expressed as hex digits plus dashes.

like image 37
Anonymous Coward Avatar answered Nov 15 '22 08:11

Anonymous Coward