fckplugin.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1.  /*
  2. * Author: Juan Carlos Raña Trabado
  3. * Plugin to insert "Wikilinks"
  4. */
  5. // Register the related command.
  6. FCKCommands.RegisterCommand( 'Wikilink', new FCKDialogCommand( 'Wikilink', FCKLang.WikilinkDlgTitle, FCKPlugins.Items['wikilink'].Path + 'fck_wikilink.html', 350, 250 ) ) ;
  7. var oPlaceholderItem = new FCKToolbarButton( 'Wikilink', FCKLang.WikilinkBtn ) ;
  8. oPlaceholderItem.IconPath = FCKPlugins.Items['wikilink'].Path + 'wikilink.gif' ;
  9. FCKToolbarItems.RegisterItem( 'Wikilink', oPlaceholderItem ) ;
  10. // Security RegExp
  11. var REG_SCRIPT = new RegExp( "< *script.*>|< *style.*>|< *link.*>|< *body.*>", "i" ) ;
  12. var REG_PROTOCOL = new RegExp( "javascript:|vbscript:|about:", "i" ) ;
  13. var REG_CALL_SCRIPT = new RegExp( "&\{.*\};", "i" ) ;
  14. var REG_EVENT = new RegExp( "onError|onUnload|onBlur|onFocus|onClick|onMouseOver|onMouseOut|onSubmit|onReset|onChange|onSelect|onAbort", "i" ) ;
  15. var REG_AUTH = new RegExp( "document\.cookie|Microsoft\.XMLHTTP", "i" ) ;// Cookie Basic
  16. var REG_NEWLINE = new RegExp( "\x0d|\x0a", "i" ) ;// TEXTAREA
  17. // Placeholders object
  18. var FCKPlaceholders = new Object() ;
  19. FCKPlaceholders.Add = function( name )
  20. {
  21. var oSpan = FCK.InsertElement( 'strong' ) ;
  22. this.SetupSpan( oSpan, name ) ;
  23. }
  24. FCKPlaceholders.SetupSpan = function( span, name )
  25. {
  26. // Call check security
  27. if ( !checkCode(name) )
  28. {
  29. alert( 'Forbiden' ) ;
  30. return false;
  31. }
  32. span.innerHTML = '[[ ' + name + ' ]]' ;
  33. }
  34. // Check security
  35. function checkCode( code )
  36. {
  37. if ( code.search( REG_SCRIPT ) != -1 )
  38. {
  39. return false ;
  40. }
  41. if ( code.search( REG_PROTOCOL ) != -1 )
  42. {
  43. return false ;
  44. }
  45. if ( code.search( REG_CALL_SCRIPT ) != -1 )
  46. {
  47. return false ;
  48. }
  49. if ( code.search( REG_EVENT ) != -1 )
  50. {
  51. return false ;
  52. }
  53. if ( code.search( REG_AUTH ) != -1 )
  54. {
  55. return false ;
  56. }
  57. if ( code.search( REG_NEWLINE ) != -1 )
  58. {
  59. return false ;
  60. }
  61. return true ;
  62. }