Skip to content

discard invalid color declarations #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions containers/win32/win32_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,20 +280,7 @@ void win32_container::draw_background( uint_ptr _hdc, const std::vector<litehtml

void win32_container::set_clip( const litehtml::position& pos, const litehtml::border_radiuses& bdr_radius )
{
litehtml::position clip_pos = pos;
litehtml::position client_pos;
get_client_rect(client_pos);
if(!valid_x)
{
clip_pos.x = client_pos.x;
clip_pos.width = client_pos.width;
}
if(!valid_y)
{
clip_pos.y = client_pos.y;
clip_pos.height = client_pos.height;
}
m_clips.push_back(clip_pos);
m_clips.push_back(pos);
}

void win32_container::del_clip()
Expand Down
13 changes: 7 additions & 6 deletions src/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void style::add_property(string_id name, const string& val, const string& baseur
add_parsed_property(_border_top_width_, width);
add_parsed_property(_border_bottom_width_, width);
}
else
else if (web_color::is_color(token, container))
{
web_color _color = web_color::from_string(token, container);
property_value color(_color, important);
Expand Down Expand Up @@ -275,7 +275,7 @@ void style::add_property(string_id name, const string& val, const string& baseur
property_value width(parse_border_width(token), important);
add_parsed_property(_id(_s(name) + "-width"), width);
}
else
else if (web_color::is_color(token, container))
{
web_color color = web_color::from_string(token, container);
add_parsed_property(_id(_s(name) + "-color"), property_value(color, important));
Expand Down Expand Up @@ -338,11 +338,12 @@ void style::add_property(string_id name, const string& val, const string& baseur
case _border_bottom_color_:
case _border_left_color_:
case _border_right_color_:
{
web_color color = web_color::from_string(val, container);
add_parsed_property(name, property_value(color, important));
if (web_color::is_color(val, container))
{
web_color color = web_color::from_string(val, container);
add_parsed_property(name, property_value(color, important));
}
break;
}

// Parse border radius shorthand properties
case _border_bottom_left_radius_:
Expand Down
11 changes: 11 additions & 0 deletions test/render/css-2-invalid-color.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Check if invalid color declarations are discarded. The text should be red. -->
<!doctype html>
<style>
p {
color: red;
color: reddit;
color: 0; /* valid in quirks mode */
}
</style>

<p>text
Binary file added test/render/css-2-invalid-color.htm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.