Skip to content

Commit

Permalink
[8045] Use std::tolower() with std::transform() correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
korydraughn committed Dec 6, 2024
1 parent 9a7a55e commit 02ea5b3
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 17 deletions.
3 changes: 2 additions & 1 deletion lib/core/include/irods/authentication_plugin_framework.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <fmt/format.h>
#include <nlohmann/json.hpp>

#include <cctype>
#include <functional>
#include <memory>
#include <string>
Expand Down Expand Up @@ -117,7 +118,7 @@ namespace irods::experimental::auth
using plugin_type = authentication_base;

std::string scheme = _scheme;
std::transform(scheme.begin(), scheme.end(), scheme.begin(), ::tolower);
std::transform(scheme.begin(), scheme.end(), scheme.begin(), [](unsigned char _ch) { return std::tolower(_ch); });

const std::string name = fmt::format("irods_auth_plugin-{}_{}", scheme, _type);

Expand Down
3 changes: 2 additions & 1 deletion lib/core/include/irods/experimental_plugin_framework.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

// =-=-=-=-=-=-=-
// stl includes
#include <cctype>
#include <sstream>
#include <string>
#include <iostream>
Expand Down Expand Up @@ -148,7 +149,7 @@ namespace irods::experimental::api {
std::transform(lower.begin(),
lower.end(),
lower.begin(),
::tolower );
[](unsigned char _ch) { return std::tolower(_ch); });

base* plugin{};
auto err = irods::load_plugin<base>(
Expand Down
3 changes: 2 additions & 1 deletion lib/core/include/irods/irods_query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <fmt/format.h>

#include <algorithm>
#include <cctype>
#include <string>
#include <vector>

Expand Down Expand Up @@ -48,7 +49,7 @@ namespace irods
lowered.begin(),
lowered.end(),
lowered.begin(),
::tolower);
[](unsigned char _ch) { return std::tolower(_ch); });

if(GEN_STR == lowered) {
return GENERAL;
Expand Down
3 changes: 2 additions & 1 deletion lib/core/src/clientLogin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <fmt/format.h>

#include <cctype>
#include <cerrno>
#include <cstdint>
#include <cstring>
Expand Down Expand Up @@ -344,7 +345,7 @@ int clientLogin(rcComm_t* _comm, const char* _context, const char* _scheme_overr
// =-=-=-=-=-=-=-
// ensure scheme is lower case for comparison
std::string lower_scheme = auth_scheme;
std::transform( auth_scheme.begin(), auth_scheme.end(), auth_scheme.begin(), ::tolower );
std::transform( auth_scheme.begin(), auth_scheme.end(), auth_scheme.begin(), [](unsigned char _ch) { return std::tolower(_ch); });

// =-=-=-=-=-=-=-
// filter out the pam auth as it is an extra special
Expand Down
3 changes: 2 additions & 1 deletion lib/core/src/irods_buffer_encryption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <openssl/aes.h>
#include <openssl/md5.h>

#include <cctype>
#include <iostream>
#include <sstream>
#include <iomanip>
Expand Down Expand Up @@ -67,7 +68,7 @@ namespace irods {
algorithm_.begin(),
algorithm_.end(),
algorithm_.begin(),
::tolower );
[](unsigned char _ch) { return std::tolower(_ch); });

// =-=-=-=-=-=-=-
// select some sane defaults
Expand Down
9 changes: 5 additions & 4 deletions lib/hasher/src/checksum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "irods/rodsKeyWdDef.h"
#include "irods/rcMisc.h"

#include <cctype>
#include <cstdio>
#include <ctime>
#include <cstring>
Expand Down Expand Up @@ -59,7 +60,7 @@ int chksumLocFile(
env_scheme.begin(),
env_scheme.end(),
env_scheme.begin(),
::tolower );
[](unsigned char _ch) { return std::tolower(_ch); });
}

// =-=-=-=-=-=-=-
Expand All @@ -75,7 +76,7 @@ int chksumLocFile(
hash_scheme.begin(),
hash_scheme.end(),
hash_scheme.begin(),
::tolower );
[](unsigned char _ch) { return std::tolower(_ch); });
}
else {
hash_scheme = env_scheme;
Expand All @@ -88,12 +89,12 @@ int chksumLocFile(
hash_scheme.begin(),
hash_scheme.end(),
hash_scheme.begin(),
::tolower );
[](unsigned char _ch) { return std::tolower(_ch); });
std::transform(
env_scheme.begin(),
env_scheme.end(),
env_scheme.begin(),
::tolower );
[](unsigned char _ch) { return std::tolower(_ch); });


// =-=-=-=-=-=-=-
Expand Down
2 changes: 1 addition & 1 deletion plugins/database/src/db_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,7 @@ irods::error db_debug_op(
mode.begin(),
mode.end(),
mode.begin(),
::tolower );
[](unsigned char _ch) { return std::tolower(_ch); });

// =-=-=-=-=-=-=-
// if mode contains 'sql' then turn SQL logging on
Expand Down
5 changes: 3 additions & 2 deletions server/api/src/rsFileChksum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <fmt/format.h>

#include <algorithm>
#include <cctype>
#include <climits>
#include <string>
#include <string_view>
Expand Down Expand Up @@ -132,7 +133,7 @@ int fileChksum(rsComm_t* rsComm,
hash_scheme.begin(),
hash_scheme.end(),
hash_scheme.begin(),
::tolower );
[](unsigned char _ch) { return std::tolower(_ch); });

std::string hash_policy;
try {
Expand Down Expand Up @@ -302,7 +303,7 @@ int file_checksum(RsComm* _comm,
catch (const irods::exception&) {}

// Make sure the read parameter is lowercased.
std::transform(hash_scheme.begin(), hash_scheme.end(), hash_scheme.begin(), ::tolower);
std::transform(hash_scheme.begin(), hash_scheme.end(), hash_scheme.begin(), [](unsigned char _ch) { return std::tolower(_ch); });

std::string_view hash_policy;
try {
Expand Down
7 changes: 2 additions & 5 deletions server/icat/src/icatHighLevelRoutines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

// =-=-=-=-=-=-=-
// stl includes
#include <cctype> // For std::tolower
#include <string>
#include <iostream>
#include <sstream>
Expand All @@ -50,11 +51,7 @@ int chlDebug(
// =-=-=-=-=-=-=-
// run tolower on mode
std::string mode( _mode );
std::transform(
mode.begin(),
mode.end(),
mode.begin(),
::tolower );
std::transform( mode.begin(), mode.end(), mode.begin(), [](unsigned char _ch) { return std::tolower(_ch); });

// =-=-=-=-=-=-=-
// if mode contains 'sql' then turn SQL logging on
Expand Down

0 comments on commit 02ea5b3

Please sign in to comment.