Escape special characters for like sql searches
This commit is contained in:
@@ -23,14 +23,14 @@ namespace StringUtils
|
||||
{
|
||||
template<>
|
||||
std::optional<API::Subsonic::Id>
|
||||
readAs(const std::string& str)
|
||||
readAs(std::string_view str)
|
||||
{
|
||||
return API::Subsonic::IdFromString(str);
|
||||
}
|
||||
|
||||
template<>
|
||||
std::optional<bool>
|
||||
readAs(const std::string& str)
|
||||
readAs(std::string_view str)
|
||||
{
|
||||
if (str == "true")
|
||||
return true;
|
||||
|
||||
@@ -90,10 +90,10 @@ namespace StringUtils
|
||||
{
|
||||
template<>
|
||||
std::optional<API::Subsonic::Id>
|
||||
readAs(const std::string& str);
|
||||
readAs(std::string_view str);
|
||||
|
||||
template<>
|
||||
std::optional<bool>
|
||||
readAs(const std::string& str);
|
||||
readAs(std::string_view str);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,12 @@ namespace API::Subsonic
|
||||
{
|
||||
|
||||
std::optional<Id>
|
||||
IdFromString(const std::string& id)
|
||||
IdFromString(const std::string_view id)
|
||||
{
|
||||
if (id == "root")
|
||||
return Id {Id::Type::Root};
|
||||
|
||||
std::vector<std::string> values {StringUtils::splitString(id, "-")};
|
||||
std::vector<std::string_view> values {StringUtils::splitString(id, "-")};
|
||||
if (values.size() != 2)
|
||||
return std::nullopt;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ struct Id
|
||||
Database::IdType value {};
|
||||
};
|
||||
|
||||
std::optional<Id> IdFromString(const std::string& id);
|
||||
std::optional<Id> IdFromString(std::string_view id);
|
||||
std::string IdToString(const Id& id);
|
||||
|
||||
} // namespace API::Subsonic
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace StringUtils
|
||||
{
|
||||
template<>
|
||||
std::optional<API::Subsonic::ClientVersion>
|
||||
readAs(const std::string& str)
|
||||
readAs(std::string_view str)
|
||||
{
|
||||
// Expects "X.Y.Z"
|
||||
const auto numbers {StringUtils::splitString(str, ".")};
|
||||
@@ -1454,7 +1454,7 @@ handleSearchRequestCommon(RequestContext& context, bool id3)
|
||||
// Mandatory params
|
||||
std::string query {getMandatoryParameterAs<std::string>(context.parameters, "query")};
|
||||
|
||||
std::vector<std::string> keywords {StringUtils::splitString(query, " ")};
|
||||
std::vector<std::string_view> keywords {StringUtils::splitString(query, " ")};
|
||||
|
||||
// Optional params
|
||||
std::size_t artistCount {getParameterAs<std::size_t>(context.parameters, "artistCount").value_or(20)};
|
||||
|
||||
Reference in New Issue
Block a user