diff options
| author | 2021-05-10 22:54:16 +0100 | |
|---|---|---|
| committer | 2021-05-10 22:54:16 +0100 | |
| commit | 7b92cf28664da516cfe5ec1390a672e358c15424 (patch) | |
| tree | 23a12a678c95909f44a1251e5b2392def09bb46b /src/modules/m_spanningtree/utils.cpp | |
| parent | Refactor the hex encoding function. (diff) | |
Extract percent encoding logic from spanningtree to inspstring.
Diffstat (limited to 'src/modules/m_spanningtree/utils.cpp')
| -rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 8d454dbc3..1eea08317 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -382,23 +382,12 @@ std::string SpanningTreeUtilities::BuildLinkString(uint16_t proto, Module* mod) if (data.empty()) return ""; // No link data. - static const char* hextable = "0123456789ABCDEF"; - bool first = true; - for (const auto& [name, value] : data) + for (Module::LinkData::const_iterator iter = data.begin(); iter != data.end(); ++iter) { - if (!first) + if (iter != data.begin()) buffer << '&'; - first = false; - buffer << name << '='; - for (const auto& chr : value) - { - // TODO: extract URL encoding logic to inspstring. - unsigned char uchr = static_cast<unsigned char>(chr); - if (isalnum(uchr)) - buffer << uchr; - else - buffer << '%' << hextable[uchr >> 4] << hextable[uchr & 15]; - } + + buffer << iter->first << '=' << Percent::Encode(iter->second); } } |
