Add syntax recheck guard

This commit is contained in:
Acid Chicken (硫酸鶏) 2019-01-25 22:18:01 +09:00
parent 8c7e56207b
commit e61c84056c
No known key found for this signature in database
GPG key ID: 5388F56C75B677A1

View file

@ -377,6 +377,18 @@ export const pack = async (
} }
//#endregion //#endregion
if ((() => { // Recheck syntax
const match = _note.text && _note.text.match(/<\/?!?nya>/ig) || [];
const stack: string[] = [];
for (const tag of [...match]
.map(x => x.toLocaleLowerCase()))
if (tag.includes('/')) {
if (stack.pop() !== tag.replace('/', ''))
return false;
} else
stack.push(tag);
return !stack.length;
})()) {
const nyamap: { [x: string]: string } = { const nyamap: { [x: string]: string } = {
//#region nyaize: ja-JP //#region nyaize: ja-JP
'な': 'にゃ', 'な': 'にゃ',
@ -416,6 +428,7 @@ export const pack = async (
_note.text += stack[0] && nyamap[head] || head; _note.text += stack[0] && nyamap[head] || head;
} }
} }
}
if (!opts.skipHide) { if (!opts.skipHide) {
await hideNote(_note, meId); await hideNote(_note, meId);