Fix possible Unicode exception in Directives parsing
This commit is contained in:
parent
7ff287511d
commit
0b4119ce12
@ -124,7 +124,7 @@ void Directives::parse(String&& directives) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Entry> newList;
|
List<Entry> entries;
|
||||||
StringView view(directives);
|
StringView view(directives);
|
||||||
StringView prefix = "";
|
StringView prefix = "";
|
||||||
view.forEachSplitView("?", [&](StringView split, size_t beg, size_t end) {
|
view.forEachSplitView("?", [&](StringView split, size_t beg, size_t end) {
|
||||||
@ -132,7 +132,7 @@ void Directives::parse(String&& directives) {
|
|||||||
if (beg == 0) {
|
if (beg == 0) {
|
||||||
try {
|
try {
|
||||||
ImageOperation operation = imageOperationFromString(split);
|
ImageOperation operation = imageOperationFromString(split);
|
||||||
newList.emplace_back(std::move(operation), beg, end);
|
entries.emplace_back(std::move(operation), beg, end);
|
||||||
}
|
}
|
||||||
catch (StarException const& e) {
|
catch (StarException const& e) {
|
||||||
prefix = split;
|
prefix = split;
|
||||||
@ -141,18 +141,18 @@ void Directives::parse(String&& directives) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ImageOperation operation = NullImageOperation();
|
ImageOperation operation = NullImageOperation();
|
||||||
newList.emplace_back(std::move(operation), beg, end);
|
entries.emplace_back(std::move(operation), beg, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (newList.empty() && !prefix.empty()) {
|
if (entries.empty() && !prefix.empty()) {
|
||||||
shared.reset();
|
shared.reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared = std::make_shared<Shared const>(std::move(newList), std::move(directives), prefix);
|
shared = std::make_shared<Shared const>(std::move(entries), std::move(directives), prefix);
|
||||||
if (view.size() < 1000) { // Pre-load short enough directives
|
if (view.utf8().size() < 1000) { // Pre-load short enough directives
|
||||||
for (auto& entry : shared->entries)
|
for (auto& entry : shared->entries)
|
||||||
entry.loadOperation(*shared);
|
entry.loadOperation(*shared);
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ ImageOperation imageOperationFromString(StringView string) {
|
|||||||
bits.emplace_back(split);
|
bits.emplace_back(split);
|
||||||
});
|
});
|
||||||
|
|
||||||
String type = bits.at(0);
|
StringView const& type = bits.at(0);
|
||||||
|
|
||||||
if (type == "hueshift") {
|
if (type == "hueshift") {
|
||||||
return HueShiftImageOperation::hueShiftDegrees(lexicalCast<float>(bits.at(1)));
|
return HueShiftImageOperation::hueShiftDegrees(lexicalCast<float>(bits.at(1)));
|
||||||
|
Loading…
Reference in New Issue
Block a user