You are not logged in.

Dear visitor, welcome to Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.


Tuesday, March 24th 2015, 8:39pm

Possible bug found in a krpano javascript method triggered by third party Array.prototype manipulation.

I've run across a possible bug in the HTML5 krpano viewer version 1.17.4 (branding free) and it appears the same bug also exists in krpano 1.19 pre-release. I'll try to give as much detail as I can to reproduce the bug.

The bug in krpano is revealed by a third party javascript library that adds methods to the Array.prototype. The third party code does something like this:

Source code

Array.prototype.contains = function() {}

Although manipulating the Array prototype is generally considered a bad practice, there can be legitimate reasons for doing so.

The krpano javascript appears to be using a for-in loop ( Ex: for(var x in a) ) instead of for(var x = 0; x < a.length; x++) to loop through the contents of an array. The for-in loop enumerates through the members of an object which gives unexpected results since it also loops through the members of the Array.prototype (it also loops through the function names). Here is a stack overflow question / answer that provides more detail about why the for-in loop should be avoided when looping through an Array:…such-a-bad-idea

Krpano appears to have this for-in loop inside of encrypted / minified function named embedhtml5(). I found this function name inside of the unbranded version of the krpano javascript code. Here is the code inside that function that contains the for-in loop:

Source code

if ((a = b) && "null" != a) {
	   if (_[41] == typeof a) {
	       b = a.split("&");
	       a = {};	
       for (var j in b)
	          e = b[j].split("="), a[e[0]] = e[1]
	   for (var p in a)
	       "xml" != p && L(p, a[p])

This is minified code inside of the embedhtml5() function. You can see that the variable b is an Array and that a for-in loop is being used to enumerate through it's members.

If you want to see this bug in action, it can be observed if you disable flash and visit this URL in Chrome:

Once the first panorama loads, pan to the right and click on the large orange arrow and a javascript error will be thrown inside the above mentioned for-in loop. The transition to the next pano will not complete because of the javascript error that is thrown.

Please let me know if you need any additional details to reproduce this error or have any questions.



Wednesday, March 25th 2015, 7:13am


this was a bug in the embedding script and is fixed since version 1.17.5:

When updating you would also need to update the embedding script.

Best regards,


Wednesday, March 25th 2015, 2:09pm


You're the best. The for in loop that I thought was in krpano 1.19 pre-release was actually in a different minified third party js library. I tested again and took a closer look and you are correct, the bug is fixed in the latest version. Thank you for the quick response!