Changeset 468


Ignore:
Timestamp:
03/03/06 16:04:39 (12 years ago)
Author:
wymsy
Message:

Bug fix: reg exp that extracted tags could crash the browser on comments containing an unmatched '<';

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/GetHtml/get-html.js

    r448 r468  
    5454/*19*/  new RegExp().compile(/(<pre[^>]*>)(\s|[^\s])*?(<\/pre>)/g),//find content inside pre tags 
    5555/*20*/  new RegExp().compile(/(^|<!--(\s|\S)*?-->)((\s|\S)*?)(?=<!--(\s|\S)*?-->|$)/g),//find content NOT inside comments 
    56 /*21*/  new RegExp().compile(/\S*=""/g) //find empty attributes 
     56/*21*/  new RegExp().compile(/\S*=""/g), //find empty attributes 
     57/*22*/  new RegExp().compile(/<!--[\s\S]*?-->|<\?[\s\S]*?\?>|<[^>]*>/g) //find all tags, including comments and php 
    5758]; 
    5859 
     
    132133HTMLArea.getHTML = function(root, outputRoot, editor) { 
    133134        var html = ""; 
     135        var c = HTMLArea.RegExpCache; 
    134136 
    135137        if(root.nodeType == 11) {//document fragment 
     
    141143                        temp.appendChild(j.cloneNode(true)); 
    142144            } 
    143             html += temp.innerHTML.replace(/<[^\?!][^>]*>/gi, function(tag){return editor.cleanHTML(tag)}); 
     145            html += temp.innerHTML.replace(c[22], function(tag){ 
     146                        if(/^<[!\?]/.test(tag)) return tag; //skip comments and php tags 
     147                        else return editor.cleanHTML(tag)}); 
    144148 
    145149        } else { 
     
    167171                //pass tags to cleanHTML() one at a time 
    168172                //includes support for htmlRemoveTags config option 
    169                 html += innerhtml.replace(/<((<[^>]*>)*|[^<>]*)*>/gi, function(tag){ 
     173                html += innerhtml.replace(c[22], function(tag){ 
    170174                        if(/^<[!\?]/.test(tag)) return tag; //skip comments and php tags 
    171175                        else if(!(editor.config.htmlRemoveTags && editor.config.htmlRemoveTags.test(tag.replace(/<([^\s>\/]+)/,'$1')))) 
Note: See TracChangeset for help on using the changeset viewer.