X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fctcpparser.cpp;h=8c43ffb38ab55dd4a1ac7c14d1b9a5f78e0e22c0;hp=d2da8413a2dd41ec36b2cd749ed9f994dcb5da69;hb=8582c2ad5708a1972c85bea1cf8d81ad3ece4814;hpb=80f22eedcd34e1fc021f5d30fe67a56955dc9083 diff --git a/src/core/ctcpparser.cpp b/src/core/ctcpparser.cpp index d2da8413..8c43ffb3 100644 --- a/src/core/ctcpparser.cpp +++ b/src/core/ctcpparser.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -47,7 +47,7 @@ CtcpParser::CtcpParser(CoreSession *coreSession, QObject *parent) void CtcpParser::setStandardCtcp(bool enabled) { - QByteArray XQUOTE = QByteArray("\134"); + QByteArray XQUOTE = QByteArray(R"(\)"); if (enabled) _ctcpXDelimDequoteHash[XQUOTE + XQUOTE] = XQUOTE; else @@ -171,6 +171,32 @@ void CtcpParser::parse(IrcEventRawMessage *e, Message::Type messagetype) ? Message::Redirected : Message::None; + bool isStatusMsg = false; + + // First remove all statusmsg prefix characters that are not also channel prefix characters. + while (e->network()->isStatusMsg(e->target()) && !e->network()->isChannelName(e->target())) { + isStatusMsg = true; + e->setTarget(e->target().remove(0, 1)); + } + + // Then continue removing statusmsg characters as long as removing the character will still result in a + // valid channel name. This prevents removing the channel prefix character if said character is in the + // overlap between the statusmsg characters and the channel prefix characters. + while (e->network()->isStatusMsg(e->target()) && e->network()->isChannelName(e->target().remove(0, 1))) { + isStatusMsg = true; + e->setTarget(e->target().remove(0, 1)); + } + + // If any statusmsg characters were removed, Flag the message as a StatusMsg. + if (isStatusMsg) { + flags |= Message::StatusMsg; + } + + // For self-messages, pass the flag on to the message, too + if (e->testFlag(EventManager::Self)) { + flags |= Message::Self; + } + if (coreSession()->networkConfig()->standardCtcp()) parseStandard(e, messagetype, dequotedMessage, ctcptype, flags); else