Merge branch 'master' into sasl

Conflicts:
	include/znc/Client.h
	src/Client.cpp
	src/Modules.cpp
	test/integration/tests/modules.cpp
This commit is contained in:
Alexey Sokolov
2025-02-13 20:37:32 +00:00
381 changed files with 12248 additions and 4121 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2004-2023 ZNC, see the NOTICE file for details.
* Copyright (C) 2004-2025 ZNC, see the NOTICE file for details.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,9 +14,10 @@
* limitations under the License.
*/
#include <string_view>
#include <znc/Message.h>
#include <znc/Utils.h>
#include "bpstd/string_view.hpp"
CMessage::CMessage(const CString& sMessage) {
Parse(sMessage);
@@ -80,6 +81,16 @@ void CMessage::SetParams(const VCString& vsParams) {
}
}
void CMessage::SetParams(VCString&& vsParams) {
m_vsParams = std::move(vsParams);
m_bColon = false;
if (m_eType == Type::Text || m_eType == Type::Notice ||
m_eType == Type::Action || m_eType == Type::CTCP) {
InitType();
}
}
CString CMessage::GetParam(unsigned int uIdx) const {
if (uIdx >= m_vsParams.size()) {
return "";
@@ -165,7 +176,7 @@ void CMessage::Parse(const CString& sMessage) {
// Find the end of the first word
const char* p = begin;
while (p < end && *p != ' ') ++p;
bpstd::string_view result(begin, p - begin);
std::string_view result(begin, p - begin);
begin = p;
// Prepare for the following word
while (begin < end && *begin == ' ') ++begin;
@@ -175,12 +186,12 @@ void CMessage::Parse(const CString& sMessage) {
// <tags>
m_mssTags.clear();
if (begin < end && *begin == '@') {
bpstd::string_view svTags = next_word().substr(1);
std::vector<bpstd::string_view> vsTags;
std::string_view svTags = next_word().substr(1);
std::vector<std::string_view> vsTags;
// Split by ';'
while (true) {
auto delim = svTags.find_first_of(';');
if (delim == bpstd::string_view::npos) {
if (delim == std::string_view::npos) {
vsTags.push_back(svTags);
break;
}
@@ -188,10 +199,10 @@ void CMessage::Parse(const CString& sMessage) {
svTags = svTags.substr(delim + 1);
}
// Save key and value
for (bpstd::string_view svTag : vsTags) {
for (std::string_view svTag : vsTags) {
auto delim = svTag.find_first_of('=');
CString sKey = std::string(delim == bpstd::string_view::npos ? svTag : svTag.substr(0, delim));
CString sValue = delim == bpstd::string_view::npos ? std::string() : std::string(svTag.substr(delim + 1));
CString sKey = std::string(delim == std::string_view::npos ? svTag : svTag.substr(0, delim));
CString sValue = delim == std::string_view::npos ? std::string() : std::string(svTag.substr(delim + 1));
m_mssTags[sKey] =
sValue.Escape(CString::EMSGTAG, CString::CString::EASCII);
}
@@ -265,11 +276,12 @@ void CMessage::InitType() {
m_eType = Type::Notice;
}
} else {
std::map<CString, Type> mTypes = {
static std::map<CString, Type> mTypes = {
{"ACCOUNT", Type::Account},
{"AUTHENTICATE", Type::Authenticate},
{"AWAY", Type::Away},
{"CAP", Type::Capability},
{"CHGHOST", Type::ChgHost},
{"ERROR", Type::Error},
{"INVITE", Type::Invite},
{"JOIN", Type::Join},