14 lines
279 B
JavaScript
14 lines
279 B
JavaScript
module.exports = {
|
|
encodeHtml: function ( str, br )
|
|
{
|
|
str = ( str + "" ).replace(/&/g, "&")
|
|
.replace(/</g, "<")
|
|
.replace(/>/g, ">")
|
|
.replace(/"/g, """)
|
|
.replace(/'/g, "'")
|
|
;
|
|
if( br ) str = str.replace( /\n/g, "<br/>" );
|
|
return str;
|
|
}
|
|
}
|