HTML엔티티 문자코드 치환 함수 추가

main
이범준 1 year ago
parent 38bc7678f3
commit a10896d534

@ -140,7 +140,10 @@ $(document).ready(function() {
Accept: "application/json; charset=utf-8"
},
success : resp => {
$P.cvlcptControl.setData([resp.cvlcptInfo]);
var cvlcptInfo = resp.cvlcptInfo;
cvlcptInfo.CVLCPT_APLY_CN = escapeHTMLEntity(cvlcptInfo.CVLCPT_APLY_CN);
$P.cvlcptControl.setData([cvlcptInfo]);
var cs = $P.parentRes.getCountStatus($("#crdnId--${pageName}").val());
$("#countStauts--${pageName}").val(cs);
$P.parentRes.selectRow(crdnId);
@ -157,8 +160,9 @@ $(document).ready(function() {
/**************************************************************************
* 초기화
**************************************************************************/
$P.cvlcptControl.setData([${cvlcptInfo}]);
var cvlcptInfo = ${cvlcptInfo};
cvlcptInfo.CVLCPT_APLY_CN = escapeHTMLEntity(cvlcptInfo.CVLCPT_APLY_CN);
$P.cvlcptControl.setData([cvlcptInfo]);
var cs = $P.parentRes.getCountStatus($("#crdnId--${pageName}").val());
$("#countStauts--${pageName}").val(cs);
});

@ -223,7 +223,27 @@ function getByte(str) {
return size;
};
/**
* HTML 엔티티 문자코드를 특수문자로 치환한다.
* @return 치환된 문자열
*/
function escapeHTMLEntity(str) {
if(str == undefined || str == null){
return ""
}
var regex = /&(amp|lt|gt|quot|#39);/g;
var chars = {
'&': '&',
'&lt;': '<',
'&gt;': '>',
'&quot;': '"',
'&#39;': "'"
};
if(regex.test(str)) {
return str.replace(regex, (matched) => chars[matched] || matched);
} else {
return str;
}
}

Loading…
Cancel
Save