1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 2<!-- 3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net 4 * Copyright (C) 2003-2009 Frederico Caldeira Knabben 5 * 6 * == BEGIN LICENSE == 7 * 8 * Licensed under the terms of any of the following licenses at your 9 * choice: 10 * 11 * - GNU General Public License Version 2 or later (the "GPL") 12 * http://www.gnu.org/licenses/gpl.html 13 * 14 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 15 * http://www.gnu.org/licenses/lgpl.html 16 * 17 * - Mozilla Public License Version 1.1 or later (the "MPL") 18 * http://www.mozilla.org/MPL/MPL-1.1.html 19 * 20 * == END LICENSE == 21 * 22 * Special Chars Selector dialog window. 23--> 24<html> 25 <head> 26 <meta name="robots" content="noindex, nofollow"> 27 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 28 <style type="text/css"> 29 .Hand 30 { 31 cursor: pointer ; 32 cursor: hand ; 33 } 34 .Sample { font-size: 24px; } 35 </style> 36 <script src="common/fck_dialog_common.js" type="text/javascript"></script> 37 <script type="text/javascript"> 38/* 39 Author: R. Reid 40 url: http://www.strictly-software.com/htmlencode 41*/ 42Encoder = { 43 44 // When encoding do we convert characters into html or numerical entities 45 EncodeType : "numerical", // entity OR numerical 46 47 isEmpty : function(val){ 48 if(val){ 49 return ((val===null) || val.length==0 || /^\s+$/.test(val)); 50 }else{ 51 return true; 52 } 53 }, 54 // Convert HTML entities into numerical entities 55 HTML2Numerical : function(s){ 56 var arr1 = new Array(' ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','­','®','¯','°','±','²','³','´','µ','¶','·','¸','¹','º','»','¼','½','¾','¿','à','á','â','ã','Ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','Ö','×','ø','ù','ú','û','Ü','ý','þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ','"','&','<','>','œ','œ','š','š','ÿ','ˆ','˜',' ',' ',' ','‌','‍','‎','‏','–','—','‘','’','‚','“','”','„','†','†','‰','‹','›','€','ƒ','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','σ','τ','υ','φ','χ','ψ','ω','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','ς','σ','τ','υ','φ','χ','ψ','ω','ϑ','ϒ','ϖ','•','…','′','′','‾','⁄','℘','ℑ','ℜ','™','ℵ','←','↑','→','↓','↔','↵','←','↑','→','↓','↔','∀','∂','∃','∅','∇','∈','∉','∋','∏','∑','−','∗','√','∝','∞','∠','∧','∨','∩','∪','∫','∴','∼','≅','≈','≠','≡','≤','≥','⊂','⊃','⊄','⊆','⊇','⊕','⊗','⊥','⋅','⌈','⌉','⌊','⌋','⟨','⟩','◊','♠','♣','♥','♦'); 57 var arr2 = new Array(' ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','­','®','¯','°','±','²','³','´','µ','¶','·','¸','¹','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ','"','&','<','>','Œ','œ','Š','š','Ÿ','ˆ','˜',' ',' ',' ','‌','‍','‎','‏','–','—','‘','’','‚','“','”','„','†','‡','‰','‹','›','€','ƒ','Α','Β','Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ','Τ','Υ','Φ','Χ','Ψ','Ω','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','ς','σ','τ','υ','φ','χ','ψ','ω','ϑ','ϒ','ϖ','•','…','′','″','‾','⁄','℘','ℑ','ℜ','™','ℵ','←','↑','→','↓','↔','↵','⇐','⇑','⇒','⇓','⇔','∀','∂','∃','∅','∇','∈','∉','∋','∏','∑','−','∗','√','∝','∞','∠','∧','∨','∩','∪','∫','∴','∼','≅','≈','≠','≡','≤','≥','⊂','⊃','⊄','⊆','⊇','⊕','⊗','⊥','⋅','⌈','⌉','⌊','⌋','〈','〉','◊','♠','♣','♥','♦'); 58 return this.swapArrayVals(s,arr1,arr2); 59 }, 60 61 // Convert Numerical entities into HTML entities 62 NumericalToHTML : function(s){ 63 var arr1 = new Array(' ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','­','®','¯','°','±','²','³','´','µ','¶','·','¸','¹','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ','"','&','<','>','Œ','œ','Š','š','Ÿ','ˆ','˜',' ',' ',' ','‌','‍','‎','‏','–','—','‘','’','‚','“','”','„','†','‡','‰','‹','›','€','ƒ','Α','Β','Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ','Τ','Υ','Φ','Χ','Ψ','Ω','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','ς','σ','τ','υ','φ','χ','ψ','ω','ϑ','ϒ','ϖ','•','…','′','″','‾','⁄','℘','ℑ','ℜ','™','ℵ','←','↑','→','↓','↔','↵','⇐','⇑','⇒','⇓','⇔','∀','∂','∃','∅','∇','∈','∉','∋','∏','∑','−','∗','√','∝','∞','∠','∧','∨','∩','∪','∫','∴','∼','≅','≈','≠','≡','≤','≥','⊂','⊃','⊄','⊆','⊇','⊕','⊗','⊥','⋅','⌈','⌉','⌊','⌋','〈','〉','◊','♠','♣','♥','♦'); 64 var arr2 = new Array(' ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','­','®','¯','°','±','²','³','´','µ','¶','·','¸','¹','º','»','¼','½','¾','¿','à','á','â','ã','Ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','Ö','×','ø','ù','ú','û','Ü','ý','þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ','"','&','<','>','œ','œ','š','š','ÿ','ˆ','˜',' ',' ',' ','‌','‍','‎','‏','–','—','‘','’','‚','“','”','„','†','†','‰','‹','›','€','ƒ','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','σ','τ','υ','φ','χ','ψ','ω','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','ς','σ','τ','υ','φ','χ','ψ','ω','ϑ','ϒ','ϖ','•','…','′','′','‾','⁄','℘','ℑ','ℜ','™','ℵ','←','↑','→','↓','↔','↵','←','↑','→','↓','↔','∀','∂','∃','∅','∇','∈','∉','∋','∏','∑','−','∗','√','∝','∞','∠','∧','∨','∩','∪','∫','∴','∼','≅','≈','≠','≡','≤','≥','⊂','⊃','⊄','⊆','⊇','⊕','⊗','⊥','⋅','⌈','⌉','⌊','⌋','⟨','⟩','◊','♠','♣','♥','♦'); 65 return this.swapArrayVals(s,arr1,arr2); 66 }, 67 68 69 // Numerically encodes all unicode characters 70 numEncode : function(s){ 71 72 if(this.isEmpty(s)) return ""; 73 74 var e = ""; 75 for (var i = 0; i < s.length; i++) 76 { 77 var c = s.charAt(i); 78 if (c < " " || c > "~") 79 { 80 c = "&#" + c.charCodeAt() + ";"; 81 } 82 e += c; 83 } 84 return e; 85 }, 86 87 // HTML Decode numerical and HTML entities back to original values 88 htmlDecode : function(s){ 89 90 var c,m,d = s; 91 92 if(this.isEmpty(d)) return ""; 93 94 // convert HTML entites back to numerical entites first 95 d = this.HTML2Numerical(d); 96 97 // look for numerical entities " 98 arr=d.match(/&#[0-9]{1,5};/g); 99 100 // if no matches found in string then skip 101 if(arr!=null){ 102 for(var x=0;x<arr.length;x++){ 103 m = arr[x]; 104 c = m.substring(2,m.length-1); //get numeric part which is refernce to unicode character 105 // if its a valid number we can decode 106 if(c >= -32768 && c <= 65535){ 107 // decode every single match within string 108 d = d.replace(m, String.fromCharCode(c)); 109 }else{ 110 d = d.replace(m, ""); //invalid so replace with nada 111 } 112 } 113 } 114 115 return d; 116 }, 117 118 // encode an input string into either numerical or HTML entities 119 htmlEncode : function(s,dbl){ 120 121 if(this.isEmpty(s)) return ""; 122 123 // do we allow double encoding? E.g will & be turned into &amp; 124 dbl = dbl | false; //default to prevent double encoding 125 126 // if allowing double encoding we do ampersands first 127 if(dbl){ 128 if(this.EncodeType=="numerical"){ 129 s = s.replace(/&/g, "&"); 130 }else{ 131 s = s.replace(/&/g, "&"); 132 } 133 } 134 135 // convert the xss chars to numerical entities ' " < > 136 s = this.XSSEncode(s,false); 137 138 if(this.EncodeType=="numerical" || !dbl){ 139 // Now call function that will convert any HTML entities to numerical codes 140 s = this.HTML2Numerical(s); 141 } 142 143 // Now encode all chars above 127 e.g unicode 144 s = this.numEncode(s); 145 146 // now we know anything that needs to be encoded has been converted to numerical entities we 147 // can encode any ampersands & that are not part of encoded entities 148 // to handle the fact that I need to do a negative check and handle multiple ampersands &&& 149 // I am going to use a placeholder 150 151 // if we don't want double encoded entities we ignore the & in existing entities 152 if(!dbl){ 153 s = s.replace(/&#/g,"##AMPHASH##"); 154 155 if(this.EncodeType=="numerical"){ 156 s = s.replace(/&/g, "&"); 157 }else{ 158 s = s.replace(/&/g, "&"); 159 } 160 161 s = s.replace(/##AMPHASH##/g,"&#"); 162 } 163 164 // replace any malformed entities 165 s = s.replace(/&#\d*([^\d;]|$)/g, "$1"); 166 167 if(!dbl){ 168 // safety check to correct any double encoded & 169 s = this.correctEncoding(s); 170 } 171 172 // now do we need to convert our numerical encoded string into entities 173 if(this.EncodeType=="entity"){ 174 s = this.NumericalToHTML(s); 175 } 176 177 return s; 178 }, 179 180 // Encodes the basic 4 characters used to malform HTML in XSS hacks 181 XSSEncode : function(s,en){ 182 if(!this.isEmpty(s)){ 183 en = en || true; 184 // do we convert to numerical or html entity? 185 if(en){ 186 s = s.replace(/\'/g,"'"); //no HTML equivalent as &apos is not cross browser supported 187 s = s.replace(/\"/g,"""); 188 s = s.replace(/</g,"<"); 189 s = s.replace(/>/g,">"); 190 }else{ 191 s = s.replace(/\'/g,"'"); //no HTML equivalent as &apos is not cross browser supported 192 s = s.replace(/\"/g,"""); 193 s = s.replace(/</g,"<"); 194 s = s.replace(/>/g,">"); 195 } 196 return s; 197 }else{ 198 return ""; 199 } 200 }, 201 202 // returns true if a string contains html or numerical encoded entities 203 hasEncoded : function(s){ 204 if(/&#[0-9]{1,5};/g.test(s)){ 205 return true; 206 }else if(/&[A-Z]{2,6};/gi.test(s)){ 207 return true; 208 }else{ 209 return false; 210 } 211 }, 212 213 // will remove any unicode characters 214 stripUnicode : function(s){ 215 return s.replace(/[^\x20-\x7E]/g,""); 216 217 }, 218 219 // corrects any double encoded & entities e.g &amp; 220 correctEncoding : function(s){ 221 return s.replace(/(&)(amp;)+/,"$1"); 222 }, 223 224 225 // Function to loop through an array swaping each item with the value from another array e.g swap HTML entities with Numericals 226 swapArrayVals : function(s,arr1,arr2){ 227 if(this.isEmpty(s)) return ""; 228 var re; 229 if(arr1 && arr2){ 230 //ShowDebug("in swapArrayVals arr1.length = " + arr1.length + " arr2.length = " + arr2.length) 231 // array lengths must match 232 if(arr1.length == arr2.length){ 233 for(var x=0,i=arr1.length;x<i;x++){ 234 re = new RegExp(arr1[x], 'g'); 235 s = s.replace(re,arr2[x]); //swap arr1 item with matching item from arr2 236 } 237 } 238 } 239 return s; 240 }, 241 242 inArray : function( item, arr ) { 243 for ( var i = 0, x = arr.length; i < x; i++ ){ 244 if ( arr[i] === item ){ 245 return i; 246 } 247 } 248 return -1; 249 } 250 251} 252</script> 253 254 <script type="text/javascript"> 255 256var oEditor = window.parent.InnerDialogLoaded() ; 257 258var oSample ; 259 260function insertChar(charValue) 261{ 262 oEditor.FCKUndo.SaveUndoStep() ; 263 oEditor.FCK.InsertHtml( charValue || "" ) ; 264 window.parent.Cancel() ; 265} 266 267function insert() { 268 var entity = get_entity(); 269 270 if(!entity) return; 271 insertChar(entity); 272} 273 274function get_entity() { 275 var c = document.getElementById('char_no').value; 276 277 if(Encoder.isEmpty(c)) { 278 alert('Please enter an entity code'); 279 return false; 280 } 281//alert(c.charCodeAt(0)); 282 Encoder.EncodeType='entity'; 283 var entity = (c.charCodeAt(0) == 38) ? c : Encoder.htmlEncode('&#' + c +';'); 284 return entity; 285 286} 287 288function test() { 289 var entity = get_entity(); 290 if(!entity) return; 291 oSample.innerHTML = Encoder.htmlDecode(entity); 292} 293 294function over(td) 295{ 296 if ( ! oSample ) 297 return ; 298 oSample.innerHTML = td.innerHTML ; 299 td.className = 'LightBackground SpecialCharsOver Hand' ; 300 301 var code = td.innerHTML.charCodeAt(0); 302 303 if(code == 38) { //if starts with ampersand, use decoder 304 Encoder.EncodeType = "numerical"; 305 code = Encoder.HTML2Numerical(td.innerHTML); 306 } 307 document.getElementById('char_no').value= code; 308 309} 310 311 312function out(td) 313{ 314 if ( ! oSample ) 315 return ; 316 oSample.innerHTML = " " ; 317 td.className = 'DarkBackground SpecialCharsOut Hand' ; 318} 319 320function setDefaults() 321{ 322 // Gets the sample placeholder. 323 oSample = document.getElementById("SampleTD") ; 324 325 // First of all, translates the dialog box texts. 326 oEditor.FCKLanguageManager.TranslatePage(document) ; 327 328 window.parent.SetAutoSize( true ) ; 329} 330 331 </script> 332 </head> 333 <body onload="setDefaults()" style="overflow: hidden"> 334<span fcklang="DlgSpecialExplaination" style="font-size:120%; font-weight:bold;">Click on a character or Enter an entity number 335or code in the text box, test it and then click insert</span> 336 <table cellpadding="0" cellspacing="0" width="100%" height="100%"> 337 <tr> 338 <td width="100%"> 339 <table cellpadding="1" cellspacing="1" align="center" border="0" width="100%" height="100%"> 340 <script type="text/javascript"> 341var aChars = ["!",""","#","$","%","&","\\'","(",")","*","+","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","€","‘","’","’","“","”","–","—","¡","¢","£","¤","¥","¦","§","¨","©","ª","«","¬","®","¯","°","±","²","³","´","µ","¶","·","¸","¹","º","»","¼","½","¾","¿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ü","ý","þ","ÿ","Œ","œ","Ŵ","Ŷ","ŵ","ŷ","‚","‛","„","…","™","►","•","→","⇒","⇔","♦","≈"] ; 342 343var cols = 20 ; 344 345var i = 0 ; 346while (i < aChars.length) 347{ 348 document.write("<TR>") ; 349 for(var j = 0 ; j < cols ; j++) 350 { 351 if (aChars[i]) 352 { 353 document.write('<TD width="1%" class="DarkBackground SpecialCharsOut Hand" align="center" onclick="insertChar(\'' + aChars[i].replace(/&/g, "&") + '\')" onmouseover="over(this)" onmouseout="out(this)">') ; 354 document.write(aChars[i]) ; 355 } 356 else 357 document.write("<TD class='DarkBackground SpecialCharsOut'> ") ; 358 document.write("<\/TD>") ; 359 i++ ; 360 } 361 document.write("<\/TR>") ; 362} 363 </script> 364 </table> 365 </td> 366 <td nowrap> </td> 367 <td valign="top"> 368 <table width="40" cellpadding="0" cellspacing="0" border="0"> 369 <tr> 370 <td id="SampleTD" width="40" height="40" align="center" class="DarkBackground SpecialCharsOut Sample"> </td> 371 </tr> 372 373<!-- Entry box for entity entering codes and numbers --> 374 <tr><td> </td></tr> 375 <tr><td width= '100'> 376 <form> 377 <input type = 'text' size='15' id='char_no'> 378 <input fcklang="DlgSpecialTest" type='button' value='test' onclick="test();"><br /> 379 <input fcklang="DlgSpecialInsert" type='submit' value='insert' onclick="insert();"> 380 </form> 381 </td></tr> 382 383 </table> 384 </td> 385 </tr> 386 </table> 387 </body> 388</html> 389