차근차근/JAVA Script

한글 최신 파일에서 자동으로 추가되는 스크립트 삭제하기

예쁜꽃이피었으면 2024. 11. 11. 10:35

 

최신 버전 한글 파일 데이터를 웹에디터에 복사붙여넣기 할 때

더보기

 <!--[data-hwpjson]{
"347oPr": {
"di": "",
"dp": {
"dn": "test.hwp",
"ta": 1,
"d1": 5,
"d2": 1,
"dv": 0,
"dr": 1,
"do": 1,
"vj": "1.0",
"an": "Hancom Office Hangul",
"av": "9, 6, 1, 10908",
"ao": "WIN",
"ab": "32",
"ar": "LE",
"as": "Windows_Unknown_Version"
},
"dis": false,
"ds": {
"ti": "",
"la": "ko",
"cr": "",
"su": "",
"de": "",
"cd": "2024-11-11T10:02:38.935Z",
"md": "1601-01-01T09:00:00.000Z",
"pd": "1601-01-01T09:00:00.000Z",
"ke": ""
}
},
"dh": {
"do": {
"pa": 1,
"fo": 1,
"en": 1,
"pi": 1,
"tb": 1,
"eq": 1
},
"fo": [ ],
"cd": {
"tp": 0,
"lc": {
"af": false,
"ui": false,
"fu": false,
"dn": false,
"ul": false,
"el": false,
"at": false,
"tq": false,
"da": false,
"dw": false,
"dj": false,
"bc": false,
"bu": false,
"al": false,
"ab": false,
"ap": false,
"an": false,
"aa": false,
"ds": false,
"de": false,
"as": false,
"cp": false,
"ao": false,
"et": false,
"ay": false,
"am": false,
"a1": false,
"bt": false,
"av": false,
"dh": false,
"dp": false,
"d1": false,
"mf": false,
"bl": false,
"ag": false,
"dg": false,
"ae": false,
"df": false,
"do": false,
"dl": false,
"di": false,
"d2": false,
"d3": false,
"ob": false,
"d4": false,
"ev": false,
"d5": false,
"d6": false,
"a2": false,
"dc": false
}
},
"ld": {
"pa": "",
"pi": true,
"fo": false
}
},
"bf": {
"01DB33D56CBF043000000013": {
"id": 1,
"td": false,
"sh": false,
"st": 0,
"sc": 0,
"si": false,
"bt": 0,
"bi": false,
"cl": 0,
"bc": false,
"lt": 0,
"lw": 0,
"lc": 0,
"rt": 0,
"rw": 0,
"rc": 0,
"tt": 0,
"tw": 0,
"tc": 0,
"bbt": 0,
"bbw": 0,
"bbc": 0,
"dt": 1,
"dw": 0,
"dc": 0,
"fi": { }
},
"01DB33D56CBF043000000014": {
"id": 2,
"td": false,
"sh": false,
"st": 0,
"sc": 0,
"si": false,
"bt": 0,
"bi": false,
"cl": 0,
"bc": false,
"lt": 0,
"lw": 0,
"lc": 0,
"rt": 0,
"rw": 0,
"rc": 0,
"tt": 0,
"tw": 0,
"tc": 0,
"bbt": 0,
"bbw": 0,
"bbc": 0,
"dt": 1,
"dw": 0,
"dc": 0,
"fi": {
"wb": {
"fc": 4294967295,
"hc": 4278190080,
"al": 0,
"hs": -1
}
}
},
"01DB33D56CBF043000000015": {
"id": 3,
"td": false,
"sh": false,
"st": 0,
"sc": 0,
"si": false,
"bt": 0,
"bi": false,
"cl": 0,
"bc": false,
"lt": 1,
"lw": 1,
"lc": 0,
"rt": 1,
"rw": 1,
"rc": 0,
"tt": 1,
"tw": 1,
"tc": 0,
"bbt": 1,
"bbw": 1,
"bbc": 0,
"dt": 1,
"dw": 0,
"dc": 0,
"fi": { }
}
},
"cp": {
"01DB33D56CBF043000000016": {
"id": 0,
"he": 1000,
"tc": 0,
"sc": 4294967295,
"uf": false,
"uk": false,
"sm": 0,
"bf": "01DB33D56CBF043000000013",
"f1": "한컴바탕",
"t1": 1,
"f2": "한컴바탕",
"t2": 1,
"f3": "함초롬바탕",
"t3": 1,
"f4": "한컴바탕",
"t4": 1,
"f5": "한컴바탕",
"t5": 1,
"f6": "한컴바탕",
"t6": 1,
"f7": "한컴바탕",
"t7": 1,
"r1": 100,
"r2": 100,
"r3": 100,
"r4": 100,
"r5": 100,
"r6": 100,
"r7": 100,
"s1": 0,
"s2": 0,
"s3": 0,
"s4": 0,
"s5": 0,
"s6": 0,
"s7": 0,
"e1": 100,
"e2": 100,
"e3": 100,
"e4": 100,
"e5": 100,
"e6": 100,
"e7": 100,
"o1": 0,
"o2": 0,
"o3": 0,
"o4": 0,
"o5": 0,
"o6": 0,
"o7": 0,
"it": false,
"bo": false,
"ut": 0,
"us": 1,
"uc": 0,
"st": false,
"ss": 1,
"so": 0,
"ot": 0,
"ht": 0,
"hc": 0,
"hx": 0,
"hy": 0,
"em": false,
"en": false,
"su": false,
"sb": false
},
"01DB33D56CBF043000000017": {
"id": 1,
"he": 1000,
"tc": 0,
"sc": 4294967295,
"uf": false,
"uk": false,
"sm": 0,
"bf": "01DB33D56CBF043000000014",
"f1": "함초롬바탕",
"t1": 1,
"f2": "함초롬바탕",
"t2": 1,
"f3": "함초롬바탕",
"t3": 1,
"f4": "함초롬바탕",
"t4": 1,
"f5": "함초롬바탕",
"t5": 1,
"f6": "함초롬바탕",
"t6": 1,
"f7": "함초롬바탕",
"t7": 1,
"r1": 100,
"r2": 100,
"r3": 100,
"r4": 100,
"r5": 100,
"r6": 100,
"r7": 100,
"s1": 0,
"s2": 0,
"s3": 0,
"s4": 0,
"s5": 0,
"s6": 0,
"s7": 0,
"e1": 100,
"e2": 100,
"e3": 100,
"e4": 100,
"e5": 100,
"e6": 100,
"e7": 100,
"o1": 0,
"o2": 0,
"o3": 0,
"o4": 0,
"o5": 0,
"o6": 0,
"o7": 0,
"it": false,
"bo": false,
"ut": 0,
"us": 1,
"uc": 0,
"st": false,
"ss": 1,
"so": 0,
"ot": 0,
"ht": 0,
"hc": 0,
"hx": 0,
"hy": 0,
"em": false,
"en": false,
"su": false,
"sb": false
}
},
"tp": {
"01DB33D56CBF043000000018": {
"id": 0,
"al": false,
"ar": false,
"tp": [ ]
}
},
"nu": {
"01DB33D56CBF043000000019": {
"id": 1,
"sn": 0,
"ph": [
{
"le": 1,
"al": 0,
"ui": true,
"ai": true,
"wa": 0,
"tt": 0,
"to": 50,
"cp": "",
"uf": 0,
"st": 1,
"sf": "^1."
},
{
"le": 2,
"al": 0,
"ui": true,
"ai": true,
"wa": 0,
"tt": 0,
"to": 50,
"cp": "",
"uf": 8,
"st": 1,
"sf": "^2."
},
{
"le": 3,
"al": 0,
"ui": true,
"ai": true,
"wa": 0,
"tt": 0,
"to": 50,
"cp": "",
"uf": 0,
"st": 1,
"sf": "^3)"
},
{
"le": 4,
"al": 0,
"ui": true,
"ai": true,
"wa": 0,
"tt": 0,
"to": 50,
"cp": "",
"uf": 8,
"st": 1,
"sf": "^4)"
},
{
"le": 5,
"al": 0,
"ui": true,
"ai": true,
"wa": 0,
"tt": 0,
"to": 50,
"cp": "",
"uf": 0,
"st": 1,
"sf": "(^5)"
},
{
"le": 6,
"al": 0,
"ui": true,
"ai": true,
"wa": 0,
"tt": 0,
"to": 50,
"cp": "",
"uf": 8,
"st": 1,
"sf": "(^6)"
},
{
"le": 7,
"al": 0,
"ui": true,
"ai": true,
"wa": 0,
"tt": 0,
"to": 50,
"cp": "",
"uf": 1,
"st": 1,
"sf": "^7"
}
]
}
},
"bu": { },
"pp": {
"01DB33D56CBF04300000001A": {
"id": 0,
"ah": 0,
"av": 0,
"ht": 0,
"hi": "",
"hl": 0,
"tp": "01DB33D56CBF043000000018",
"kb": 0,
"kn": true,
"ko": false,
"kk": false,
"kl": false,
"kp": false,
"kw": 0,
"co": 0,
"fl": false,
"st": true,
"sl": false,
"ae": false,
"aa": false,
"mi": 0,
"ml": 0,
"mr": 0,
"mp": 0,
"mn": 0,
"lt": 0,
"lv": 160,
"bf": "01DB33D56CBF043000000013",
"bl": 0,
"br": 0,
"bt": 0,
"bb": 0,
"bc": false,
"bi": false
},
"01DB33D56CBF04300000001B": {
"id": 1,
"ah": 0,
"av": 0,
"ht": 0,
"hi": "",
"hl": 0,
"tp": "01DB33D56CBF043000000018",
"kb": 0,
"kn": true,
"ko": false,
"kk": false,
"kl": false,
"kp": false,
"kw": 0,
"co": 0,
"fl": false,
"st": true,
"sl": false,
"ae": false,
"aa": false,
"mi": 0,
"ml": 0,
"mr": 0,
"mp": 0,
"mn": 0,
"lt": 0,
"lv": 160,
"bf": "01DB33D56CBF043000000014",
"bl": 0,
"br": 0,
"bt": 0,
"bb": 0,
"bc": false,
"bi": false
}
},
"st": {
"01DB33D56CBF04300000001C": {
"id": 0,
"ty": 0,
"na": "바탕글",
"en": "Normal",
"pp": "01DB33D56CBF04300000001B",
"cp": "01DB33D56CBF043000000017",
"ns": "01DB33D56CBF04300000001C",
"li": 1042,
"lf": false
}
},
"mp": { },
"ro": {
"hp": "01DB33D56CBEB61000000003",
"01DB33D56CBEB61000000003": {
"np": "01DB33D56CBEB61000000004",
"id": 0,
"pp": "01DB33D56CBF04300000001B",
"si": "01DB33D56CBF04300000001C",
"bf": 3,
"ru": [
{
"cp": "01DB33D56CBF043000000017",
"ch": [
{
"cc": 2,
"ci": 1936024420,
"co": "01DB33D56CBEB61000000000"
}
,
{
"cc": 2,
"ci": 1668246628,
"co": "01DB33D56CBEB61000000001"
}
,
{
"cc": 11,
"ci": 1952607264,
"co": "01DB33D56CBEB61000000002"
}
,
{
"t": ""
}
]
}
]
},
"01DB33D56CBEB61000000004": {
"np": "01DB33D56CBEB61000000005",
"id": -2147483648,
"pp": "01DB33D56CBF04300000001B",
"si": "01DB33D56CBF04300000001C",
"bf": 0,
"ru": [
{
"cp": "01DB33D56CBF043000000017",
"ch": [
{
"t": ""
}
]
}
]
},
"01DB33D56CBEB61000000005": {
"np": "01DB33D56CBEB61000000006",
"id": -2147483648,
"pp": "01DB33D56CBF04300000001B",
"si": "01DB33D56CBF04300000001C",
"bf": 0,
"ru": [
{
"cp": "01DB33D56CBF043000000017",
"ch": [
{
"t": ""
}
]
}
]
},
"01DB33D56CBEB61000000006": {
"np": "",
"id": -2147483648,
"pp": "01DB33D56CBF04300000001A",
"si": "01DB33D56CBF04300000001C",
"bf": 0,
"ru": [
{
"cp": "01DB33D56CBF043000000016",
"ch": [
{
"t": ""
}
]
}
]
}
},
"sl": {
"01DB33D56CBEB61000000007": {
"co": "01DB33D56CBEB61000000002",
"id": 1,
"td": 0,
"lw": 0,
"va": 1,
"ll": "",
"ln": "",
"tc": {
"he": false,
"hm": false,
"pr": false,
"ed": false,
"di": false,
"bf": "01DB33D56CBF043000000015",
"ac": 0,
"ar": 0,
"sc": 1,
"sr": 1,
"sw": 20977,
"sh": 282,
"ml": 510,
"mr": 510,
"mt": 141,
"mb": 141
},
"hp": "01DB33D56CBEB61000000008"
},
"01DB33D56CBEB61000000008": {
"np": "",
"id": -2147483648,
"pp": "01DB33D56CBF04300000001B",
"si": "01DB33D56CBF04300000001C",
"bf": 0,
"ru": [
{
"cp": "01DB33D56CBF043000000017",
"ch": [
{
"t": "ㅅㄷㄴㅅ"
}
]
}
]
}
,
"01DB33D56CBEB61000000009": {
"co": "01DB33D56CBEB61000000002",
"id": 2,
"td": 0,
"lw": 0,
"va": 1,
"ll": "",
"ln": "",
"tc": {
"he": false,
"hm": false,
"pr": false,
"ed": false,
"di": false,
"bf": "01DB33D56CBF043000000015",
"ac": 1,
"ar": 0,
"sc": 1,
"sr": 1,
"sw": 20977,
"sh": 282,
"ml": 510,
"mr": 510,
"mt": 141,
"mb": 141
},
"hp": "01DB33D56CBEB6100000000A"
},
"01DB33D56CBEB6100000000A": {
"np": "",
"id": -2147483648,
"pp": "01DB33D56CBF04300000001B",
"si": "01DB33D56CBF04300000001C",
"bf": 0,
"ru": [
{
"cp": "01DB33D56CBF043000000017",
"ch": [
{
"t": ""
}
]
}
]
}
,
"01DB33D56CBEB6100000000B": {
"co": "01DB33D56CBEB61000000002",
"id": 3,
"td": 0,
"lw": 0,
"va": 1,
"ll": "",
"ln": "",
"tc": {
"he": false,
"hm": false,
"pr": false,
"ed": false,
"di": false,
"bf": "01DB33D56CBF043000000015",
"ac": 0,
"ar": 1,
"sc": 1,
"sr": 1,
"sw": 20977,
"sh": 282,
"ml": 510,
"mr": 510,
"mt": 141,
"mb": 141
},
"hp": "01DB33D56CBEB6100000000C"
},
"01DB33D56CBEB6100000000C": {
"np": "",
"id": -2147483648,
"pp": "01DB33D56CBF04300000001B",
"si": "01DB33D56CBF04300000001C",
"bf": 0,
"ru": [
{
"cp": "01DB33D56CBF043000000017",
"ch": [
{
"t": ""
}
]
}
]
}
,
"01DB33D56CBEB6100000000D": {
"co": "01DB33D56CBEB61000000002",
"id": 4,
"td": 0,
"lw": 0,
"va": 1,
"ll": "",
"ln": "",
"tc": {
"he": false,
"hm": false,
"pr": false,
"ed": false,
"di": false,
"bf": "01DB33D56CBF043000000015",
"ac": 1,
"ar": 1,
"sc": 1,
"sr": 1,
"sw": 20977,
"sh": 282,
"ml": 510,
"mr": 510,
"mt": 141,
"mb": 141
},
"hp": "01DB33D56CBEB6100000000E"
},
"01DB33D56CBEB6100000000E": {
"np": "",
"id": -2147483648,
"pp": "01DB33D56CBF04300000001B",
"si": "01DB33D56CBF04300000001C",
"bf": 0,
"ru": [
{
"cp": "01DB33D56CBF043000000017",
"ch": [
{
"t": ""
}
]
}
]
}
,
"01DB33D56CBEB6100000000F": {
"co": "01DB33D56CBEB61000000002",
"id": 5,
"td": 0,
"lw": 0,
"va": 1,
"ll": "",
"ln": "",
"tc": {
"he": false,
"hm": false,
"pr": false,
"ed": false,
"di": false,
"bf": "01DB33D56CBF043000000015",
"ac": 0,
"ar": 2,
"sc": 1,
"sr": 1,
"sw": 20977,
"sh": 282,
"ml": 510,
"mr": 510,
"mt": 141,
"mb": 141
},
"hp": "01DB33D56CBEB61000000010"
},
"01DB33D56CBEB61000000010": {
"np": "",
"id": -2147483648,
"pp": "01DB33D56CBF04300000001B",
"si": "01DB33D56CBF04300000001C",
"bf": 0,
"ru": [
{
"cp": "01DB33D56CBF043000000017",
"ch": [
{
"t": ""
}
]
}
]
}
,
"01DB33D56CBEB61000000011": {
"co": "01DB33D56CBEB61000000002",
"id": 6,
"td": 0,
"lw": 0,
"va": 1,
"ll": "",
"ln": "",
"tc": {
"he": false,
"hm": false,
"pr": false,
"ed": false,
"di": false,
"bf": "01DB33D56CBF043000000015",
"ac": 1,
"ar": 2,
"sc": 1,
"sr": 1,
"sw": 20977,
"sh": 282,
"ml": 510,
"mr": 510,
"mt": 141,
"mb": 141
},
"hp": "01DB33D56CBEB61000000012"
},
"01DB33D56CBEB61000000012": {
"np": "",
"id": -2147483648,
"pp": "01DB33D56CBF04300000001B",
"si": "01DB33D56CBF04300000001C",
"bf": 0,
"ru": [
{
"cp": "01DB33D56CBF043000000017",
"ch": [
{
"t": ""
}
]
}
]
}
},
"cs": {
"01DB33D56CBEB61000000000": {
"cc": 2,
"ci": 1936024420,
"td": 0,
"tv": false,
"sc": 1134,
"ts": 8000,
"ms": "",
"os": "01DB33D56CBF043000000019",
"gl": 0,
"gc": 0,
"gw": false,
"ns": 0,
"np": 0,
"ni": 0,
"nt": 0,
"ne": 0,
"hh": false,
"hf": false,
"hm": false,
"fb": false,
"hb": false,
"fi": false,
"hi": false,
"hp": false,
"he": false,
"sl": false,
"lr": 0,
"lc": 0,
"ld": 0,
"ls": 0,
"pp": {
"ls": false,
"wi": 59528,
"he": 84188,
"gt": 0,
"ml": 8504,
"mr": 8504,
"mt": 5668,
"mb": 4252,
"mh": 4252,
"mf": 4252,
"mg": 0
},
"fn": {
"at": 0,
"au": "",
"ap": "",
"ac": ")",
"as": false,
"ll": -1,
"lt": 1,
"lw": 1,
"lc": 0,
"sa": 850,
"sb": 567,
"st": 283
,
"nt": 0,
"nn": 1,
"pp": 0,
"pb": false
},
"en": {
"at": 0,
"au": "",
"ap": "",
"ac": ")",
"as": false,
"ll": 14692344,
"lt": 1,
"lw": 1,
"lc": 0,
"sa": 850,
"sb": 567,
"st": 0
,
"nt": 0,
"nn": 1,
"pp": 0,
"pb": false
},
"pb": [
{
"ty": 0,
"bf": "01DB33D56CBF043000000013",
"tb": true,
"hi": false,
"fi": false,
"fa": 0,
"ol": 1417,
"or": 1417,
"ot": 1417,
"ob": 1417
},
{
"ty": 1,
"bf": "01DB33D56CBF043000000013",
"tb": true,
"hi": false,
"fi": false,
"fa": 0,
"ol": 1417,
"or": 1417,
"ot": 1417,
"ob": 1417
},
{
"ty": 2,
"bf": "01DB33D56CBF043000000013",
"tb": true,
"hi": false,
"fi": false,
"fa": 0,
"ol": 1417,
"or": 1417,
"ot": 1417,
"ob": 1417
}
],
"mp": [ ]
}
,
"01DB33D56CBEB61000000001": {
"cc": 2,
"ci": 1668246628,
"ty": 0,
"la": 0,
"co": 1,
"ss": true,
"sg": 0,
"lt": 0,
"lw": 0,
"lc": 0,
"cs": [ ]
}
,
"01DB33D56CBEB61000000002": {
"cc": 11,
"ci": 1952607264,
"id": 1687361142,
"zo": 4,
"nt": 2,
"tw": 1,
"tf": 0,
"lo": false,
"swi": 41954,
"she": 3846,
"swr": 4,
"shr": 2,
"spr": false,
"pta": false,
"pal": false,
"pvr": 2,
"phr": 2,
"pva": 0,
"ph1": 0,
"pvo": 0,
"ph2": 0,
"pfw": true,
"pao": false,
"pha": false,
"ole": 283,
"ori": 283,
"oto": 283,
"obo": 283,
"ca": { },
"sc": ""
,
"pb": 2,
"rh": true,
"na": false,
"ho": false,
"if": true,
"sa": false,
"rc": 3,
"cco": 2,
"cs": 0,
"bf": "01DB33D56CBF043000000015",
"ile": 510,
"iri": 510,
"ito": 141,
"ibo": 141,
"cl": [ ],
"tr": [
[
{
"so": "01DB33D56CBEB61000000007",
"li": 1
},
{
"so": "01DB33D56CBEB61000000009",
"li": 2
}
],
[
{
"so": "01DB33D56CBEB6100000000B",
"li": 3
},
{
"so": "01DB33D56CBEB6100000000D",
"li": 4
}
],
[
{
"so": "01DB33D56CBEB6100000000F",
"li": 5
},
{
"so": "01DB33D56CBEB61000000011",
"li": 6
}
]
]
}
},
"bi": [ ],
"bidt": { }
}-->

 

와 같은 스크립트가 에디터데이터 가장 뒤에 추가된다.

단순히 추가되는 것은 에디터 화면에서는 문제가 없는데

수정이 필요한 이유는

저 스크립트 안에 있는 sh라는 단어가

waf에서 차단되기 때문에 등록/수정 시 오류가 나고 있다.

 

우선 문제점은 찾았고 

해당 스크립트를 삭제하는 코드를 추가해보자.

 

//naverEditer.js

//기존
function submitContents(elClickedObj){
	oEditors.getById["contents"].exec("UPDATE_CONTENTS_FIELD",[]); //에디터의 내용이 TEXTAREA에 적용됩니다.

	try{
    	elClickedObj.form.submit();
    }eatch(e){}
}



//수정
function submitContents(elClickedObj){
	oEditors.getById["contents"].exec("UPDATE_CONTENTS_FIELD",[]); //에디터의 내용이 TEXTAREA에 적용됩니다.

	var contentsText = document.getElementById("contents");//입력한 글
    var contentsReplaceHwp = "";
    
    var hwpStartScript = "<!--[data-jwpjson]";
    var hwpStartScriptIndex = contentsText.value.indexOf(hwpStartScript);//자르기 시작할 위치
    
	var hwpEndScript = "}-->";
    var hwpEndScriptIndex = contentsText.value.indexOf(hwpEndScript,hwpStartScript);//자르기 종료할 위치
    
    while(hwpStartScriptIndex > 0 && hwpEndScriptIndex > 0){
    	hwpStartScriptIndex = contentsText.value.indexOf(hwpStartScript);//자르기 시작할 위치
    	hwpEndScriptIndex = contentsText.value.indexOf(hwpEndScript,hwpStartScript);//자르기 종료할 위치
    	
        if(hwpStartScriptIndex > 0 && hwpEndScriptIndex > 0){
        	var hwpScript = contentsText.value.substring(hwpStartScriptIndex,hwpEndScriptIndex+4);//잘라낼 HWP스크립트
            contentsReplaceHwp = contentsText.value.replace(hwpScript,'');
            //내용 초기화
            oEditors.getById["contents"].exec("SET_IR",[""]);
            //내용 수정
            oEditors.getById["contents"].exec("PASTE_HTML",[contentsReplaceHwp]);
        }
        
        oEditors.getById["contents"].exec("UPDATE_CONTENTS_FIELD",[]);
        
    }
    

	try{
    	elClickedObj.form.submit();
    }eatch(e){}
}

 

이런 식으로 삭제해야할 부분 시작점, 끝점 찾아서 삭제 시켜서 DB에 저장하는 방식으로 함.

좀 더 다듬어야 함.

 

 

 

 

 

 

 

 

 

반응형