diff --git a/Libraries/LibWeb/SVG/ViewBox.cpp b/Libraries/LibWeb/SVG/ViewBox.cpp index 48d1146b350..bb4fa363abb 100644 --- a/Libraries/LibWeb/SVG/ViewBox.cpp +++ b/Libraries/LibWeb/SVG/ViewBox.cpp @@ -41,9 +41,13 @@ Optional try_parse_view_box(StringView string) view_box.min_y = maybe_number.value(); break; case State::Width: + if (*maybe_number < 0) + return {}; view_box.width = maybe_number.value(); break; case State::Height: + if (*maybe_number < 0) + return {}; view_box.height = maybe_number.value(); break; default: diff --git a/Tests/LibWeb/Ref/expected/wpt-import/svg/struct/reftests/reference/green-100x100.html b/Tests/LibWeb/Ref/expected/wpt-import/svg/struct/reftests/reference/green-100x100.html new file mode 100644 index 00000000000..f718ea6abfb --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/svg/struct/reftests/reference/green-100x100.html @@ -0,0 +1,2 @@ + +
diff --git a/Tests/LibWeb/Ref/input/wpt-import/svg/coordinate-systems/support/views.svg b/Tests/LibWeb/Ref/input/wpt-import/svg/coordinate-systems/support/views.svg new file mode 100644 index 00000000000..93f801a4f8d --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/svg/coordinate-systems/support/views.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/Tests/LibWeb/Ref/input/wpt-import/svg/coordinate-systems/view-invalid-viewBox.html b/Tests/LibWeb/Ref/input/wpt-import/svg/coordinate-systems/view-invalid-viewBox.html new file mode 100644 index 00000000000..4475107352c --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/svg/coordinate-systems/view-invalid-viewBox.html @@ -0,0 +1,6 @@ + +view element with invalid viewBox should be ignored + + + +