title: Javascript RegEx replacing &quot;
body: <p>I'm trying to patch the Drupal Panels module to fix <a href="http://drupal.org/node/1124042" rel="nofollow">this nasty issue</a>, which makes the AJAX errorhandler completely unreadable. The error handler has this:</p>
  
  <pre><code>// Replace all &amp;lt; and &amp;gt; by &lt; and &gt;
    error_text = error_text.replace("/&amp;(lt|gt);/g", function (m, p) { 
      return (p == "lt")? "&lt;" : "&gt;";
    });
  </code></pre>
  
  <p>I've tried two approaches:</p>
  
  <p>Adding</p>
  
  <pre><code>// Now replace all &amp;quot with ' for readability, for goodness sakes, per
    // http://drupal.org/node/1124042
    error_text = error_text.replace(/&amp;quot;/g, "'");
  </code></pre>
  
  <p>Modifying</p>
  
  <pre><code>// Replace all &amp;lt; and &amp;gt; by &lt; and &gt;
    error_text = error_text.replace("/&amp;(lt|gt|quot);/g", function (m, p) { 
      return (p == "lt")? "&lt;" : (p == "gt") ? "&gt;" : "'";
    });
  </code></pre>
  
  <p>Yet neither has worked. Little help?</p>
  
  <p>EDIT: When printed out to console (in FF4 or Chrome) The HTML entities are not shown. The resulting alert(""), however, looks like so:</p>
  
  <pre><code>An error occurred at /home/panels/ajax/editor/select-content/panel_context%3Apage-faculty_page%3Apage_faculty_page_panel_context/center.
  
  Error Description: [ { &amp;quot;command&amp;quot;: &amp;quot;settings&amp;quot;, &amp;quot;argument&amp;quot;: {    &amp;quot;basePath&amp;quot;: &amp;quot;/home/&amp;quot;, &amp;quot;admin_menu&amp;quot;: { &amp;quot;margin_top&amp;quot;: 1 }, &amp;quot;asu_webauth&amp;quot;: { &amp;quot;callapp&amp;quot;:
  &gt;&amp;quot;home&amp;quot;, quot;onLogoutURL&amp;quot;: &amp;quot;http://physics-dev.asu.edu&amp;quot; } } }, { &amp;quot;command&amp;quot;: &amp;quot;css_files&amp;quot;, &amp;quot;argument&amp;quot;: [ { &amp;quot;file&amp;quot;: &amp;quot;/home/modules/node/node.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/modules/system/defaults.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/modules/system/system.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/modules/system/system-menus.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/modules/user/user.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/sites/all/modules/admin_menu/admin_menu.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/sites/all/modules/cck/theme/content-module.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/sites/all/modules/ctools/css/ctools.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/sites/all/modules/date/date.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/sites/all/modules/filefield/filefield.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/sites/all/modules/office_hours/office_hours.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/sites/all/modules/og/theme/og.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/sites/all/modules/panels/css/panels.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/sites/all/modules/views_slideshow/contrib/views_slideshow_singleframe/views_slideshow.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/sites/all/modules/views_slideshow/contrib/views_slideshow_thumbnailhover/views_slideshow.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/misc/farbtastic/farbtastic.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/sites/all/modules/calendar/calendar.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/sites/all/modules/cck/modules/fieldgroup/fieldgroup.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; }, { &amp;quot;file&amp;quot;: &amp;quot;/home/sites/all/modules/views/css/views.css?E&amp;quot;, &amp;quot;media&amp;quot;: &amp;quot;all&amp;quot; } ] }, { &amp;quot;command&amp;quot;: &amp;quot;scripts&amp;quot;, &amp;quot;argument&amp;quot;: [ &amp;quot;/home/misc/jquery.js&amp;quot;, &amp;quot;/home/misc/drupal.js&amp;quot;, &amp;quot;/home/sites/all/modules/admin_menu/admin_menu.js&amp;quot;, &amp;quot;/home/sites/all/modules/og/og.js&amp;quot;, &amp;quot;/home/sites/all/modules/panels/js/panels.js&amp;quot;, &amp;quot;/home/sites/all/modules/views_slideshow/js/jquery.cycle.all.min.js&amp;quot;, &amp;quot;/home/sites/all/modules/views_slideshow/contrib/views_slideshow_singleframe/views_slideshow.js&amp;quot;, &amp;quot;/home/sites/all/modules/views_slideshow/contrib/views_slideshow_thumbnailhover/views_slideshow.js&amp;quot;, &amp;quot;/home/sites/all/modules/asu_webauth/asu_webauth.js&amp;quot; ] }, { &amp;quot;command&amp;quot;: &amp;quot;modal_display&amp;quot;, &amp;quot;title&amp;quot;: &amp;quot;Add content to Center&amp;quot;, &amp;quot;output&amp;quot;: &amp;quot;\x3cdiv class=\&amp;quot;panels-add-content-modal\&amp;quot;\x3e\x3cdiv class=\&amp;quot;panels-section-column panels-section-column-categories\&amp;quot;\x3e\x3cdiv class=\&amp;quot;inside\&amp;quot;\x3e\x3cdiv class=\&amp;quot;panels-categories-box\&amp;quot;\x3e\x3ca href=\&amp;quot;/home/panels/ajax/editor/select-content/panel_context%3Apage-faculty_page%3Apage_faculty_page_panel_context/center/activity\&amp;quot; class=\&amp;quot;ctools-use-ajax panels-modal-add-category\&amp;quot; title=\&amp;quot;\&amp;quot;\x3eActivity\x3c/a\x3e\x3ca href=\&amp;quot;/home/panels/ajax/editor/select-content/panel_context%3Apage-faculty_page%3Apage_faculty_page_panel_context/center/menus\&amp;quot; class=\&amp;quot;ctools-use-ajax panels-modal-add-category\&amp;quot; title=\&amp;quot;\&amp;quot;\x3eMenus\x3c/a\x3e\x3ca href=\&amp;quot;/home/panels/ajax/editor/select-content/panel_context%3Apage-faculty_page%3Apage_faculty_page_panel_context/center/miscellaneous\&amp;quot; class=\&amp;quot;ctools-use-ajax panels-modal-add-category\&amp;quot; title=\&amp;quot;\&amp;quot;\x3eMiscellaneous\x3c/a\x3e\x3ca href=\&amp;quot;/home/panels/ajax/editor/select-content/panel_context%3Apage-faculty_page%3Apage_faculty_page_panel_context/center/page-elements\&amp;quot; class=\&amp;quot;ctools-use-ajax panels-modal-add-category\&amp;quot; title=\&amp;quot;\&amp;quot;\x3ePage elements\x3c/a\x3e\x3ca href=\&amp;quot;/home/panels/ajax/editor/select-content/panel_context%3Apage-faculty_page%3Apage_faculty_page_panel_context/center/view-panes\&amp;quot; class=\&amp;quot;ctools-use-ajax panels-modal-add-category\&amp;quot; title=\&amp;quot;\&amp;quot;\x3eView panes\x3c/a\x3e\x3ca href=\&amp;quot;/home/panels/ajax/editor/select-content/panel_context%3Apage-faculty_page%3Apage_faculty_page_panel_context/center/views\&amp;quot; class=\&amp;quot;ctools-use-ajax panels-modal-add-category\&amp;quot; title=\&amp;quot;\&amp;quot;\x3eViews\x3c/a\x3e\x3ca href=\&amp;quot;/home/panels/ajax/editor/select-content/panel_context%3Apage-faculty_page%3Apage_faculty_page_panel_context/center/widgets\&amp;quot; class=\&amp;quot;ctools-use-ajax panels-modal-add-category\&amp;quot; title=\&amp;quot;\&amp;quot;\x3eWidgets\x3c/a\x3e\x3c/div\x3e\x3cdiv class=\&amp;quot;content-type-button clear-block\&amp;quot;\x3e\x3ca href=\&amp;quot;/home/panels/ajax/editor/add-pane/panel_context%3Apage-faculty_page%3Apage_faculty_page_panel_context/center/node/node\&amp;quot; class=\&amp;quot;ctools-use-ajax panels-modal-add-config\&amp;quot; title=\&amp;quot;Add a node from your site as content.\&amp;quot;\x3e\x3cimg src=\&amp;quot;/home/sites/all/modules/ctools/plugins/content_types/node/icon_node.png\&amp;quot; alt=\&amp;quot;\&amp;quot; title=\&amp;quot;\&amp;quot; width=\&amp;quot;16\&amp;quot; height=\&amp;quot;16\&amp;quot; /\x3e\x3c/a\x3e\x3cdiv\x3e\x3ca href=\&amp;quot;/home/panels/ajax/editor/add-pane/panel_context%3Apage-faculty_page%3Apage_faculty_page_panel_context/center/node/node\&amp;quot; class=\&amp;quot;ctools-use-ajax panels-modal-add-config\&amp;quot; title=\&amp;quot;Add a node from your site as content.\&amp;quot;\x3eExisting node\x3c/a\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv class=\&amp;quot;content-type-button clear-block\&amp;quot;\x3e\x3ca href=\&amp;quot;/home/panels/ajax/editor/add-pane/panel_context%3Apage-faculty_page%3Apage_faculty_page_panel_context/center/custom/custom\&amp;quot; class=\&amp;quot;ctools-use-ajax panels-modal-add-config\&amp;quot; title=\&amp;quot;Create a completely custom piece of HTML content.\&amp;quot;\x3e\x3cimg src=\&amp;quot;/home/sites/all/modules/ctools/images/no-icon.png\&amp;quot; alt=\&amp;quot;\&amp;quot; title=\&amp;quot;\&amp;quot; width=\&amp;quot;16\&amp;quot; height=\&amp;quot;16\&amp;quot; /\x3e\x3c/a\x3e\x3cdiv\x3e\x3ca href=\&amp;quot;/home/panels/ajax/editor/add-pane/panel_context%3Apage-faculty_page%3Apage_faculty_page_panel_context/center/custom/custom\&amp;quot; class=\&amp;quot;ctools-use-ajax panels-modal-add-config\&amp;quot; title=\&amp;quot;Create a completely custom piece of HTML content.\&amp;quot;\x3eNew custom content\x3c/a\x3e\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv class=\&amp;quot;panels-categories-description\&amp;quot;\x3eContent options are divided by category. Please select a category from the left to proceed.\x3c/div\x3e\x3c/div\x3e&amp;quot; } ]
  </code></pre>