📜 ⬆️ ⬇️

Internet Explorer 11 Bookmarklets: Storage Format, Limits and Silent Rules, Treacherous Bug

After two bookmarklets that worked in Google Chrome and Firefox at once refused to work in Internet Explorer 11, and did not issue any error messages to the console and showed no signs of life at all, I began to figure out what was wrong.

At first I decided that it was a limit on the length of the URL, and thus on the length of the bookmarklet. In IE 7, the limit was 2083 characters, in IE 11, according to experimenters' assurances, the limit was increased. It was necessary to find out experimentally what the border is now.

But first, a small preface.
')
Google Chrome stores bookmarks in JSON, Firefox - in the sqlite database. Therefore, the names of the bookmarks can be arbitrary. IE stores each bookmark as a separate file, for example, in the% userprofile% \ Favorites \ Links folder. Therefore, the browser will adjust the names of the bookmarks so that they fit the file system standards (replace question marks, for example). Therefore, in IE, two bookmarks with the same name cannot be in the same folder, but they can be in Google Chrome and Firefox (bookmarks in them can even be without a name, only with a site icon or a standard substitute).

Google Chrome and Firefox allow you to create a bookmark from scratch by entering the name and URL, including the bookmarklet code, into the appropriate fields. At the same time, Google Chrome and Firefox remove newlines in the code, and with whitespace they do differently: the first partially deletes them, and partially leaves them as far as the syntax permits; the second turns the whitespace characters into% 20 characters, as the functions encodeURI () and encodeURIComponent () do. After creation, both browsers allow editing both regular bookmarks and bookmarklets.

In IE, you can add a bookmarklet only by dragging the link to the Favorites panel. Editing the code after creating a bookmark in the browser itself is no longer possible (it cannot even be viewed in the browser: only the beginning can be seen in the pop-up tip, and the call to the bookmark properties opens a window that does not contain a URL or code field). But there is a workaround: you can edit the bookmark files in the folder mentioned.

These files have the .url extension, and are identical in format to the .ini text files. Here is an example of a simple saved bookmarklet file for IE 11.

  [{000214A0-0000-0000-C000-000000000046}]
 Prop3 = 19.15
 [InternetShortcut]
 URL = javascript: (function () {alert ('Hello, world!');}) ()
 IDList =
 [Bookmarklet]
 ExtendedURL = javascript: (function () {alert ('Hello, world!');}) () 


This template can be used as a template: if you replace both lines of code in it and save it with a valid file name in the folder, a new bookmarklet appears on the Favorites panel. Thus it is necessary to take into account such a feature: IE reads bookmarks once during the opening of a window or tab. If you edit the file, the window or tab will still operate on the old version. If you close the window and re-open it or open a new tab, then file changes will take effect for them. Therefore, there may be such a situation that clicking on the same tab in five different tabs may produce five different results if you edited a file before each tab opening. The confusion is aggravated by the fact that IE saves running processes: you can close a tab, IE will leave the child process in memory and use it when opening another tab, and the legacy of the bookmarks read will go to this, not entirely new tab. Therefore, when testing the code of bookmarklets and directly editing their files, either restart one window, or open new tabs without closing the previous ones (it will probably be easier to use the console).

Now about the file format, or rather about the part of interest to us. As we can see, the URL or bookmarklet code is stored in two duplicate keys. But between them there is both a distinction and a relationship. Experimentally, we managed to find out the following rules:

1. URL key limit = 2083 characters. Key limit ExtendedURL = 5119 characters.
2. With a bookmarklet code of more than 2083 characters, IE terminates the value of the URL key by exactly 2083 characters, cutting off all remaining mechanically. He obviously takes the working code only from the second key.
3. With a bookmarklet code of more than 5119 characters, IE leaves 2057 characters in the URL key, and the entire code in ExtendedURL . When adding such a bookmark to Favorites, no warnings are made to the user, the bookmarklet then simply does not work, with unsuccessful launches there are no error messages in the console either .
4. With a large code, the first 2083 characters of both keys must match up to the character . If they differ by at least one sign, or if the first key is at least 2082 characters, the bookmarklet will not work.

Having figured out these rules, I checked my broken bookmarklets for consistency. There were no violations. They were more than three thousand characters, all the format rules in the files were followed.

It can be seen, it is necessary to check with different options and the size of the code, maybe there are still hidden rules, I thought. Or there are uncatchable errors, and you need to insert try-catch . In general, prepare for an unpredictable number of tests.

And then I noticed that both files have a strange similarity in one strange detail. In both, the URL key value ended in a space. I wondered earlier why IE had inserted a space at the end of the line. But, having looked narrowly, I understood that IE did not insert anything. By a funny coincidence, both codes of my bookmarklets had a space on the 2083 character. And it dawned on me how terrible, and so saving guess, which was immediately justified by trials. I had to formulate another rule of bookmarklets for IE 11, which is actually a bug rather than a rule:

5. If in the code of the bookmarklet in place of 2083 characters there is a space and, thus, the space will be the last character of the URL key, such bookmarklet will not work. As with the listed violations of the rules, the user will not receive any preliminary warnings or subsequent error messages.

From all this, at least two tips that create bookmarklets for IE 11 follow:

- Check the character limit of 5119 characters.
- Check the absence of a space on the 2083 character, or clean up spaces to the maximum, or encode javascript: URL using functions, or paste it from Firefox bookmarks.

Finally, I will give an example of an .url file with a threshold size of keys for those who want to verify what is described:

test.url
 [{000214A0-0000-0000-C000-000000000046}]
 Prop3 = 19.15
 [InternetShortcut]
 URL = javascript: (function () {alert ( '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456  789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456  789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123
 IDList =
 [Bookmarklet]
 ExtendedURL = javascript: (function () {alert ( '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678  9 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678  9 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678  9 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678  9 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678  9 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12 ');}) ()


This is the workbook bookmarklet code. It will stop working if you:

- increase at least by a sign one of the keys or both keys (even by the same sign);
- reduce the first key by at least one character;
- replace at least one character in one of the keys without identically changing the same character in another key;
- in place of 2083 characters in both keys, put a space (in the first key it is the last character, in the second key - one of the characters in the middle of the line).

Written in the hope of saving someone time and health.

If someone knows the site, where it makes sense to send a message about this questionable behavior (like bugzilla.mozilla.org for Firefox or code.google.com/p/chromium/issues/list for Google Chrome), please let us know. Thanks for attention.

Source: https://habr.com/ru/post/263443/


All Articles