From deb7852349c32fae75a61c73984f0dd9f7a80373 Mon Sep 17 00:00:00 2001 From: sebaszm <45654185+sebaszm@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:30:25 +0100 Subject: [PATCH] [JSONRPC] Allow nested prefixes in method designator (#1834) --- Source/core/JSONRPC.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/core/JSONRPC.h b/Source/core/JSONRPC.h index cae566a4e..7d63204ae 100644 --- a/Source/core/JSONRPC.h +++ b/Source/core/JSONRPC.h @@ -379,11 +379,14 @@ namespace Core { } if (method.empty() == false) { - idx0 = method.find(TCHAR(':')); + idx0 = method.rfind(TCHAR(':')); - if (method.size() < (idx0 + 2)) { + if (method.size() < (idx0 + 1)) { idx0 = string::npos; } + else { + idx0--; + } if (idx0 != string::npos) { idx = method.find(TCHAR('#')); @@ -433,7 +436,10 @@ POP_WARNING() if (lookup != string::npos) { size_t prefix = designator.find_first_of(':', lookup + 1); - method = (designator.substr(begin, lookup - begin) + designator.substr(prefix, end - prefix)); + method = designator.substr(begin, lookup - begin); + if (prefix != string::npos) { + method += designator.substr(prefix, end - prefix); + } } else { method = designator.substr(begin, end - begin); @@ -449,12 +455,12 @@ POP_WARNING() { string prefix; - size_t end = designator.find_first_of(':'); + size_t end = designator.find_last_of(':'); if (end != string::npos) { size_t begin = designator.find_last_of('.', end) + 1; size_t lookup = designator.find_first_of('#', begin); - prefix = designator.substr(begin, std::min(lookup,end) - begin); + prefix = designator.substr(begin, std::min(lookup,end - 1) - begin); } return (prefix);