More generic parsing of background fill name.

This commit is contained in:
levlam 2023-03-01 21:26:49 +03:00
parent 69c85f0df8
commit 86b4213a8c
2 changed files with 5 additions and 5 deletions

View File

@ -143,7 +143,7 @@ Result<BackgroundFill> BackgroundFill::get_background_fill(Slice name) {
} }
auto get_color = [](Slice color_string) -> Result<int32> { auto get_color = [](Slice color_string) -> Result<int32> {
auto r_color = hex_to_integer_safe<uint32>(color_string); auto r_color = hex_to_integer_safe<uint32>(url_decode(color_string, true));
if (r_color.is_error() || color_string.size() > 6) { if (r_color.is_error() || color_string.size() > 6) {
return Status::Error(400, "WALLPAPER_INVALID"); return Status::Error(400, "WALLPAPER_INVALID");
} }
@ -179,7 +179,7 @@ Result<BackgroundFill> BackgroundFill::get_background_fill(Slice name) {
Slice prefix("rotation="); Slice prefix("rotation=");
if (begins_with(parameters, prefix)) { if (begins_with(parameters, prefix)) {
rotation_angle = to_integer<int32>(parameters.substr(prefix.size())); rotation_angle = to_integer<int32>(url_decode(parameters.substr(prefix.size()), true));
if (!is_valid_rotation_angle(rotation_angle)) { if (!is_valid_rotation_angle(rotation_angle)) {
rotation_angle = 0; rotation_angle = 0;
} }
@ -276,7 +276,7 @@ void BackgroundType::apply_parameters_from_link(Slice name) {
} }
} }
string BackgroundType::get_link() const { string BackgroundType::get_link(bool is_first) const {
string mode; string mode;
if (is_blurred_) { if (is_blurred_) {
mode = "blur"; mode = "blur";
@ -304,7 +304,7 @@ string BackgroundType::get_link() const {
return link; return link;
} }
case Type::Fill: case Type::Fill:
return fill_.get_link(true); return fill_.get_link(is_first);
default: default:
UNREACHABLE(); UNREACHABLE();
return string(); return string();

View File

@ -107,7 +107,7 @@ class BackgroundType {
void apply_parameters_from_link(Slice name); void apply_parameters_from_link(Slice name);
string get_link() const; string get_link(bool is_first = true) const;
bool has_equal_type(const BackgroundType &other) const { bool has_equal_type(const BackgroundType &other) const {
return type_ == other.type_; return type_ == other.type_;