Unverified Commit e40827c2 authored by Robert Mikołajuk's avatar Robert Mikołajuk
Browse files

Issue #168883 by poiu, vokiel: Fix (remove) the eval() usage inside JavaScript files.

parent e0e65234
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -92,8 +92,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
    });
    $("#input-formats :checkbox:eq(0)").trigger('change');

    $(".cke_load_toolbar").click(function() {
      var buttons = eval('Drupal.settings.'+$(this).attr("id"));
    $(".cke_load_toolbar", "#ckeditor-admin-profile-form").click(function() {
      var id = $(this).attr("id").replace(/[^\w]/g, '');
      if (typeof(Drupal.settings[id]) == 'undefined') {
        return false;
      }
      var buttons = Drupal.settings[id];
      var text = "[\n";
      for(i in buttons) {
        if (typeof buttons[i] == 'string'){
+25 −3
Original line number Diff line number Diff line
@@ -37,7 +37,9 @@ if (typeof window.CKEDITOR_BASEPATH === 'undefined') {
    $("#" + textarea_id).addClass("ckeditor-processed");

    var textarea_settings = false;
    ckeditor_obj.input_formats[ckeditor_obj.elements[textarea_id]].toolbar = eval(ckeditor_obj.input_formats[ckeditor_obj.elements[textarea_id]].toolbar);
    if (typeof(ckeditor_obj.input_formats[ckeditor_obj.elements[textarea_id]].toolbar) != 'object') {
      ckeditor_obj.input_formats[ckeditor_obj.elements[textarea_id]].toolbar = Drupal.ckeditorToolbarToArray(ckeditor_obj.input_formats[ckeditor_obj.elements[textarea_id]].toolbar);
    }
    textarea_settings = ckeditor_obj.input_formats[ckeditor_obj.elements[textarea_id]];

    var drupalTopToolbar = $('#toolbar, #admin-menu', Drupal.overlayChild ? window.parent.document : document);
@@ -123,7 +125,16 @@ if (typeof window.CKEDITOR_BASEPATH === 'undefined') {

    if (typeof textarea_settings['js_conf'] != 'undefined'){
      for (var add_conf in textarea_settings['js_conf']){
        textarea_settings[add_conf] = eval(textarea_settings['js_conf'][add_conf]);
        var data;
        if (add_conf == 'toolbar') {
          data = Drupal.ckeditorToolbarToArray(textarea_settings['js_conf'][add_conf]);
        } else if (typeof textarea_settings['js_conf'][add_conf] === "boolean" ) {
          data = textarea_settings['js_conf'][add_conf];
        } else {
          data = JSON.parse(textarea_settings['js_conf'][add_conf].replace(/'/g, '"'));
        }

        textarea_settings[add_conf] = data;
      }
    }

@@ -141,7 +152,7 @@ if (typeof window.CKEDITOR_BASEPATH === 'undefined') {
      textarea_settings = Drupal.ckeditorLoadPlugins(textarea_settings);
      Drupal.ckeditorInstance = CKEDITOR.replace(textarea_id, textarea_settings);
    }
  }
  };

  Drupal.ckeditorOn = function(textarea_id, run_filter) {

@@ -256,6 +267,17 @@ if (typeof window.CKEDITOR_BASEPATH === 'undefined') {
    }
  };

  if (typeof(Drupal.ckeditorToolbarToArray) == 'undefined') {
    Drupal.ckeditorToolbarToArray = function (toolbar) {
      toolbar = toolbar.replace(/\r?\n|\r/gmi, '')
          .replace(/\s/gmi, '')
          .replace(/([a-zA-Z0-9]+?):/g, '"$1":')
          .replace(/'/g, '"');

      return JSON.parse(toolbar);
    };
  }

  /**
 * Ajax support
 */
+16 −5
Original line number Diff line number Diff line
@@ -76,18 +76,18 @@ jQuery(document).ready(function() {
        jQuery("li.sortableItem").mouseout(function(){
            jQuery(".sortableList").sortable("enable");
        });
    }
    };

    Drupal.ckeditorToolbarReload = function() {
        jQuery(".sortableList").sortable('destroy');
        jQuery(".sortableRow").sortable('destroy');
        jQuery("li.sortableItem").unbind();
        Drupal.ckeditorToolbaInit();
    }
    };

    Drupal.ckeditorToolbarUsedRender = function() {
        var toolbar = jQuery('#edit-toolbar').val();
        toolbar = eval(toolbar);
        toolbar = Drupal.ckeditorToolbarToArray(toolbar);
        var html = '<div class="sortableListDiv"><span class="sortableListSpan"><ul class="sortableRow">';
        var group = false;

@@ -115,13 +115,13 @@ jQuery(document).ready(function() {
        }
        html += '</ul></span></div>';
        jQuery('#groupLayout').empty().append(html);
    }
    };

    Drupal.ckeditorToolbarAllRender = function() {
        var toolbarUsed = jQuery('#edit-toolbar').val();
        var toolbarAll = Drupal.settings.cke_toolbar_buttons_all;

        var htmlArray = new Array();
        var htmlArray = [];
        var html = '';

        for (var i in toolbarAll) {
@@ -144,6 +144,17 @@ jQuery(document).ready(function() {
            html += '<div class="sortableListDiv"><span class="sortableListSpan"><ul class="sortableRow">' + htmlArray[j] + '</ul></span></div>';
        }
        jQuery('#allButtons').empty().append(html);
    };

    if (typeof(Drupal.ckeditorToolbarToArray) == 'undefined') {
        Drupal.ckeditorToolbarToArray = function (toolbar) {
            toolbar = toolbar.replace(/\r?\n|\r/gmi, '')
                .replace(/\s/gmi, '')
                .replace(/([a-zA-Z0-9]+?):/g, '"$1":')
                .replace(/'/g, '"');

            return JSON.parse(toolbar);
        };
    }

    Drupal.ckeditorToolbaInit();