mirror of
https://github.com/pieartsy/PluralFlux.git
synced 2026-04-14 20:15:28 +10:00
fixed regex to escape proxy tags that match a normal regex
This commit is contained in:
@@ -57,9 +57,13 @@ msgh.parseProxyTags = async function (authorId, content, attachmentUrl= null){
|
|||||||
if(content.startsWith(splitProxy[0]) && content.endsWith(splitProxy[1])) {
|
if(content.startsWith(splitProxy[0]) && content.endsWith(splitProxy[1])) {
|
||||||
if (attachmentUrl) throw new Error(enums.err.ATTACHMENTS_NOT_ALLOWED);
|
if (attachmentUrl) throw new Error(enums.err.ATTACHMENTS_NOT_ALLOWED);
|
||||||
proxyMessage.proxy = member.proxy;
|
proxyMessage.proxy = member.proxy;
|
||||||
const removePrefix = new RegExp("^" + splitProxy[0]);
|
let escapedPrefix = splitProxy[0].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
const removeSuffix = new RegExp(splitProxy[1] + "$");
|
let escapedSuffix = splitProxy[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
proxyMessage.message = content.replace(removePrefix, "").replace(removeSuffix, "");;
|
console.log(escapedPrefix, escapedSuffix);
|
||||||
|
escapedPrefix = new RegExp("^" + escapedPrefix);
|
||||||
|
escapedSuffix = new RegExp(escapedSuffix + "$")
|
||||||
|
proxyMessage.message = content.replace(escapedPrefix, "").replace(escapedSuffix, "");
|
||||||
|
console.log(proxyMessage.message);
|
||||||
if (proxyMessage.message.length === 0) throw new Error(enums.err.NO_MESSAGE_SENT_WITH_PROXY);
|
if (proxyMessage.message.length === 0) throw new Error(enums.err.NO_MESSAGE_SENT_WITH_PROXY);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user