From 71bc77076d8233a2340a14f8eefe8a6bcadcf30c Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 21 Sep 2008 02:46:20 +0000 Subject: コマンド文字をHTMLエスケープ git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@19662 d0d07461-0603-4401-acd4-de1884942a52 --- bufferecho.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bufferecho.js') diff --git a/bufferecho.js b/bufferecho.js index c1826a9..dc287be 100644 --- a/bufferecho.js +++ b/bufferecho.js @@ -3,7 +3,7 @@ * @name bufferecho.js * @description Display results of JavaScript to a buffer(browser) instead of commandline-buffer * @description-ja JavaScript実行結果をコマンドライン・バッファではなくバッファ(ブラウザ)に表示 - * @version 0.1a + * @version 0.1 * ==/VimperatorPlugin== */ liberator.plugins.buffer_echo = (function(){ @@ -18,6 +18,11 @@ function execute(str){ } return result; } +function htmlEscape(str){ + return str.replace("&","&","g") + .replace("<","<","g") + .replace(">",">","g"); +} liberator.commands.addUserCommand(['bufferecho','becho'],'Display results of JavaScript to a buffer(browser)', function(args, special){ @@ -34,7 +39,7 @@ var manager = { open: function(str, forceNewTab) { var result = execute(str); if (typeof(result) == "object") result = liberator.util.objectToString(result,true); - var data = '

' + str + '

' + result + '
'; + var data = '

' + htmlEscape(str) + '

' + result + '
'; if (liberator.buffer.title == title && !forceNewTab){ this.append(data); return; -- cgit v1.2.3