diff --git a/misc/ahah.js b/misc/ahah.js index e2a8659f53..f371d5aa0f 100644 --- a/misc/ahah.js +++ b/misc/ahah.js @@ -73,7 +73,7 @@ Drupal.ahah = function(base, element_settings) { // The 'this' variable will not persist inside of the options object. var ahah = this; var options = { - url: ahah.url, + url: Drupal.sanitizeAjaxUrl(ahah.url), data: ahah.button, beforeSubmit: function(form_values, element_settings, options) { return ahah.beforeSubmit(form_values, element_settings, options); @@ -96,6 +96,7 @@ Drupal.ahah = function(base, element_settings) { } }, dataType: 'json', + jsonp: false, type: 'POST' }; diff --git a/misc/autocomplete.js b/misc/autocomplete.js index c5176727c4..7083d88ec6 100644 --- a/misc/autocomplete.js +++ b/misc/autocomplete.js @@ -278,8 +278,9 @@ Drupal.ACDB.prototype.search = function (searchString) { // Ajax GET request for autocompletion $.ajax({ type: "GET", - url: db.uri +'/'+ Drupal.encodeURIComponent(searchString), + url: Drupal.sanitizeAjaxUrl(db.uri +'/'+ Drupal.encodeURIComponent(searchString)), dataType: 'json', + jsonp: false, success: function (matches) { if (typeof matches['status'] == 'undefined' || matches['status'] != 0) { db.cache[searchString] = matches; diff --git a/misc/drupal.js b/misc/drupal.js index a85b8f8579..b56892a6a8 100644 --- a/misc/drupal.js +++ b/misc/drupal.js @@ -270,6 +270,23 @@ Drupal.getSelection = function (element) { return { 'start': element.selectionStart, 'end': element.selectionEnd }; }; +/** + * Sanitizes a URL for use with jQuery.ajax(). + * + * @param url + * The URL string to be sanitized. + * + * @return + * The sanitized URL. + */ +Drupal.sanitizeAjaxUrl = function (url) { + var regex = /\=\?(&|$)/; + while (url.match(regex)) { + url = url.replace(regex, ''); + } + return url; +} + /** * Build an error message from ahah response. */