From d2cca1b0e18b2b18efcca603719b1a511528f63e Mon Sep 17 00:00:00 2001 From: Yuya Nishiyama Date: Fri, 9 Nov 2012 18:10:25 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=86=E3=83=B3=E3=83=97=E3=83=AC=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=81=AE=E3=82=A8=E3=82=B9=E3=82=B1=E3=83=BC=E3=83=97?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/utils/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/utils/index.js b/lib/utils/index.js index 7a239d1..59bf453 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -3,16 +3,20 @@ var util = require('util'); exports.nl2br = function(str) { - return str.replace(/\n/g, '
'); + if (str) { + return str.replace(/\n/g, '
'); + } }; exports.escHtml = function(str) { + if (str) { str = str.replace(/&/g, '&'); str = str.replace(//g, '>'); str = str.replace(/"/g, '"'); str = str.replace(/\\/g, '¥'); return str; + } }; // Error