Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Got an issue on working ctools with the others external script, which extends Array object. For example:
Array.prototype.contains=function(obj) {
for(var i=0; i<this.length; i++) {
if(this[i] === obj) return i;
}
return -1;
};
the problem is with
Drupal.CTools.AJAX.commands.scripts = function(data) {
...
for (i in data.argument) {
we are processing an array as an object and as the result it have "function contains()" in values, when it passed to Drupal.CTools.AJAX.getPath it breaks javascript when it tries get indexOf('?') from function.
there are two possible solutions how to fix it:
1. add validation of value in Drupal.CTools.AJAX.getPath
2. replace for ... in with for loop
both of the fixes added to patch.
Comment | File | Size | Author |
---|---|---|---|
#4 | array-extender-breaks-ajax-responder-1401518-4.patch | 861 bytes | gumanist |
#2 | array-extender-breaks-ajax-responder-1401518-2.patch | 853 bytes | gumanist |
array-extender-breaks-ajax-responder.patch | 652 bytes | gumanist |
Comments
Comment #1
andypostfor..in iteration should be used only for Objects!!!
This is over-engineering
same should be applied for css!
Comment #2
gumanist CreditAttribution: gumanist commentedRemoved redundant validation for link, updated iterator for css.
Comment #3
nod_Please be careful of implicit global variables, add
var
to variables declaration,for (var i = 0...
.Comment #4
gumanist CreditAttribution: gumanist commentedThanks for your suggession. You are totally right. Patch updated.
Comment #5
yarroha CreditAttribution: yarroha commentedWorks fine for me.
Comment #6
andypostMakes sense and now looks good
Comment #7
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted and pushed.