Changeset 425


Ignore:
Timestamp:
11/21/05 14:54:02 (8 years ago)
Author:
wymsy
Message:

Fix for ticket #591; comments containing tags are now handled correctly; pre (and script) tags containing comments are now handled correctly (ticket #253)

File:
1 edited

Legend:

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

    r422 r425  
    5050/*16*/  new RegExp().compile(/<(div|p|h[1-6]|table|tr|td|th|ul|ol|li|blockquote|object|html|head|body|script)( [^>]*)?>/g),//blocklevel opening tag 
    5151/*17*/  new RegExp().compile(/<(br|hr|img|embed|param|pre|meta|link|title)[^>]*>/g),//singlet tag 
    52 /*18*/  new RegExp().compile(/(^|<\/(pre|script)>)(\s|[^\s])*?(<(pre|script)[^>]*>|$)/g),//exclude content between pre and script tags 
     52/*18*/  new RegExp().compile(/(^|<\/(pre|script)>)(\s|[^\s])*?(<(pre|script)[^>]*>|$)/g),//find content NOT inside pre and script tags 
    5353/*19*/  new RegExp().compile(/(<pre[^>]*>)(\s|[^\s])*?(<\/pre>)/g),//find content inside pre tags 
    54 /*20*/  new RegExp().compile(/(^|<!--(\s|\S)*?-->)((\s|\S)*?)(?=<!--(\s|\S)*?-->|$)/g)//exclude comments 
     54/*20*/  new RegExp().compile(/(^|<!--(\s|\S)*?-->)((\s|\S)*?)(?=<!--(\s|\S)*?-->|$)/g)//find content NOT inside comments 
    5555]; 
    5656 
     
    9494                s = s.replace(c[19], function(str){return str.replace(/<br \/>/g,"\n")}); 
    9595        } 
    96         s = s.replace(c[20], function(st,$1,$2,$3) { //exclude comments 
    97           strn = $3.replace(c[18], function(string) { //skip pre and script tags 
    98                 string = string.replace(/[\n\r]/gi, " ").replace(/\s+/gi," ").replace(c[14], function(str) { 
     96        s = s.replace(c[18], function(strn) { //skip pre and script tags 
     97          strn = strn.replace(c[20], function(st,$1,$2,$3) { //exclude comments 
     98                string = $3.replace(/[\n\r]/gi, " ").replace(/\s+/gi," ").replace(c[14], function(str) { 
    9999                        if (str.match(c[16])) { 
    100100                                var s = "\n" + HTMLArea.__sindent + str; 
     
    117117                        return str; // this won't actually happen 
    118118                }); 
    119                 return string; 
    120       });return $1 + strn; 
     119                return $1 + string; 
     120          });return strn; 
    121121    }); 
    122122    if (s.charAt(0) == "\n") { 
     
    162162                        innerhtml = editor._doc.body.innerHTML; 
    163163                } 
    164                 //pass tags to cleanHTML() one at a time; ignore comments and php tags 
     164                //pass tags to cleanHTML() one at a time 
    165165                //includes support for htmlRemoveTags config option 
    166                 html += innerhtml.replace(/<[^\?!][^>]*>/gi, function(tag){ 
    167                         if(!(editor.config.htmlRemoveTags && editor.config.htmlRemoveTags.test(tag.replace(/<([^\s>\/]+)/,'$1')))) 
    168                         return editor.cleanHTML(tag); 
     166                html += innerhtml.replace(/<((<[^>]*>)*|[^<>]*)*>/gi, function(tag){ 
     167                        if(/^<[!\?]/.test(tag)) return tag; //skip comments and php tags 
     168                        else if(!(editor.config.htmlRemoveTags && editor.config.htmlRemoveTags.test(tag.replace(/<([^\s>\/]+)/,'$1')))) 
     169                                return editor.cleanHTML(tag); 
    169170                        else return ''}); 
    170171                //IE drops  all </li> tags in a list except the last one 
Note: See TracChangeset for help on using the changeset viewer.