Ver Fonte

[ST24PRJ-517][결함][SCM] 공지 팝업 깨짐

hss há 4 anos atrás
pai
commit
1e9f860e31
1 ficheiros alterados com 19 adições e 1 exclusões
  1. 19 1
      src/main/webapp/WEB-INF/views/board/NoticePopupForm.html

+ 19 - 1
src/main/webapp/WEB-INF/views/board/NoticePopupForm.html

@@ -85,6 +85,24 @@
 // 			},
 // 		});
 // 	}
+
+String.prototype.replaceHTML = function (){ //테그제거 및 XSS 변환
+	var str = this;
+	str = str.split(/&lt;/g).join("<");
+	str = str.split(/&gt;/g).join(">");
+	str = str.split(/&nbsp;/g).join(" ");
+	str = str.split(/&quot;/g).join('"');
+	str = str.split(/&ldquo;/g).join('"');
+	str = str.split(/&rdquo;/g).join('"');
+	str = str.split(/&lsquo;/g).join("'");
+	str = str.split(/&rsquo;/g).join("'");
+	str = str.split(/&middot;/g).join('·');
+	str = str.split(/&amp;/g).join("&");
+	str = str.replace(/<br\/>/ig, "\n");
+	str = str.replace(/<(\/)?([a-zA-Z]*)(\s[a-zA-Z]*=[^>]*)?(\s)*(\/)?>/ig, "");
+	console.log(str);
+	return str;
+}
 	
 	$('#btnCloseNotice').on('click', function() {
 		gagajf.setCookie("CK_NOTICE_CLOSE", "Y", 1);
@@ -100,7 +118,7 @@
 						$.each(result, function(idx, item) {
 							let tag = '<div class="swiper-slide">\n';
 							tag += '	<div class="title">' + item.noticeTitle + '</div>\n';
-							tag += '	<div class="content">' + item.noticeContent + '</div>\n';
+							tag += '	<div class="content">' + item.noticeContent.replaceHTML() + '</div>\n';
 							
 							if (item.fileList.length > 0) {
 								tag += '	<ul class="download">\n';