mirror of https://gitee.com/bigwinds/arangodb
issue 568.1: restrict analyzer name to characters allowed for collection names (#8923)
This commit is contained in:
parent
f3a2eaf6d9
commit
6a5785be40
|
@ -871,6 +871,16 @@ arangodb::Result IResearchAnalyzerFeature::emplaceAnalyzer( // emplace
|
|||
irs::string_ref const& properties, // analyzer properties
|
||||
irs::flags const& features // analyzer features
|
||||
) {
|
||||
// validate analyzer name
|
||||
auto split = splitAnalyzerName(name);
|
||||
|
||||
if (!TRI_vocbase_t::IsAllowedName(false, arangodb::velocypack::StringRef(split.second.c_str(), split.second.size()))) {
|
||||
return arangodb::Result( // result
|
||||
TRI_ERROR_BAD_PARAMETER, // code
|
||||
std::string("invalid characters in analyzer name '") + std::string(split.second) + "'"
|
||||
);
|
||||
}
|
||||
|
||||
// validate that features are supported by arangod an ensure that their
|
||||
// dependencies are met
|
||||
for(auto& feature: features) {
|
||||
|
|
|
@ -583,6 +583,14 @@ SECTION("test_emplace") {
|
|||
CHECK((true == !feature.get(arangodb::StaticStrings::SystemDatabase + "::test_analyzer11")));
|
||||
}
|
||||
|
||||
// add invalid (name has invalid char)
|
||||
{
|
||||
arangodb::iresearch::IResearchAnalyzerFeature::EmplaceResult result;
|
||||
arangodb::iresearch::IResearchAnalyzerFeature feature(s.server);
|
||||
CHECK((false == feature.emplace(result, arangodb::StaticStrings::SystemDatabase + "::test_analyzer12+", "TestAnalyzer", "abc").ok()));
|
||||
CHECK((true == !feature.get(arangodb::StaticStrings::SystemDatabase + "::test_analyzer12+")));
|
||||
}
|
||||
|
||||
// add static analyzer
|
||||
{
|
||||
arangodb::iresearch::IResearchAnalyzerFeature::EmplaceResult result;
|
||||
|
|
Loading…
Reference in New Issue