Changeset 898 for trunk/modules/Gecko


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

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

File:
1 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) {} 
Note: See TracChangeset for help on using the changeset viewer.