Changeset 898


Ignore:
Timestamp:
10/10/07 19:20:10 (7 years ago)
Author:
ray
Message:

#1081 Control character is not being removed inside SCRIPT tags or HEAD when switching from textmode to htmlmode

Location:
trunk/modules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/Gecko/Gecko.js

    r894 r898  
    692692Xinha.prototype.setCC = function ( target ) 
    693693{ 
     694  var cc = this.cc; 
    694695  try 
    695696  { 
    696697    if ( target == "textarea" ) 
    697698    { 
    698       var ta = this._textArea; 
     699          var ta = this._textArea; 
    699700      var index = ta.selectionStart; 
    700701      var before = ta.value.substring( 0, index ) 
    701702      var after = ta.value.substring( index, ta.value.length ); 
    702703 
    703       if ( after.match(/^[^<]*>/) ) 
     704      if ( after.match(/^[^<]*>/) ) // make sure cursor is in an editable area (outside tags, script blocks, and inside the body) 
    704705      { 
    705706        var tagEnd = after.indexOf(">") + 1; 
    706         ta.value = before + after.substring( 0, tagEnd ) + this.cc + after.substring( tagEnd, after.length ); 
    707       } 
    708       else ta.value = before + this.cc + after; 
     707        ta.value = before + after.substring( 0, tagEnd ) + cc + after.substring( tagEnd, after.length ); 
     708      } 
     709      else ta.value = before + cc + after; 
     710          ta.value = ta.value.replace(new RegExp ('(<script[^>]*>[^'+cc+']*?)('+cc+')([^'+cc+']*?<\/script>)'), "$1$3$2"); 
     711          ta.value = ta.value.replace(new RegExp ('^([^'+cc+']*)('+cc+')([^'+cc+']*<body[^>]*>)(.*?)'), "$1$3$2$4"); 
    709712    } 
    710713    else 
    711714    { 
    712715      var sel = this.getSelection(); 
    713       sel.getRangeAt(0).insertNode( document.createTextNode( this.cc ) ); 
     716      sel.getRangeAt(0).insertNode( document.createTextNode( cc ) ); 
    714717    } 
    715718  } catch (e) {} 
  • trunk/modules/InternetExplorer/InternetExplorer.js

    r865 r898  
    436436Xinha.prototype.setCC = function ( target ) 
    437437{ 
     438  var cc = this.cc; 
    438439  if ( target == "textarea" ) 
    439440  { 
     
    441442    var pos = document.selection.createRange(); 
    442443    pos.collapse(); 
    443     pos.text = this.cc; 
    444     var index = ta.value.indexOf( this.cc ); 
     444    pos.text = cc; 
     445    var index = ta.value.indexOf( cc ); 
    445446    var before = ta.value.substring( 0, index ); 
    446     var after  = ta.value.substring( index + this.cc.length , ta.value.length ); 
     447    var after  = ta.value.substring( index + cc.length , ta.value.length ); 
    447448     
    448     if ( after.match(/^[^<]*>/) ) 
     449        if ( after.match(/^[^<]*>/) ) // make sure cursor is in an editable area (outside tags, script blocks, and inside the body) 
    449450    { 
    450451      var tagEnd = after.indexOf(">") + 1; 
    451       ta.value = before + after.substring( 0, tagEnd ) + this.cc + after.substring( tagEnd, after.length ); 
    452     } 
    453     else ta.value = before + this.cc + after; 
     452      ta.value = before + after.substring( 0, tagEnd ) + cc + after.substring( tagEnd, after.length ); 
     453    } 
     454    else ta.value = before + cc + after; 
     455    ta.value = ta.value.replace(new RegExp ('(<script[^>]*>[^'+cc+']*?)('+cc+')([^'+cc+']*?<\/script>)'), "$1$3$2"); 
     456    ta.value = ta.value.replace(new RegExp ('^([^'+cc+']*)('+cc+')([^'+cc+']*<body[^>]*>)(.*?)'), "$1$3$2$4"); 
    454457  } 
    455458  else 
     
    460463    { 
    461464      var control = r.item(0); 
    462       control.outerHTML += this.cc; 
     465      control.outerHTML += cc; 
    463466    } 
    464467    else 
    465468    { 
    466469      r.collapse(); 
    467       r.text = this.cc; 
     470      r.text = cc; 
    468471    } 
    469472  } 
Note: See TracChangeset for help on using the changeset viewer.