浏览代码

LibWeb: Avoid crash for unsupported length unit in SVG elements

Acid3 sets 1em as the y coordinate of one of external SVG fonts, we
don't support that yet. Ignore unsupported unit instead of crashing.
Andi Gallo 2 年之前
父节点
当前提交
ead56e88db
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp

+ 4 - 4
Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp

@@ -35,13 +35,13 @@ void SVGTextContentElement::parse_attribute(DeprecatedFlyString const& name, Dep
     SVGGraphicsElement::parse_attribute(name, value);
 
     if (name == SVG::AttributeNames::x) {
-        m_x = AttributeParser::parse_coordinate(value).value();
+        m_x = AttributeParser::parse_coordinate(value).value_or(m_x);
     } else if (name == SVG::AttributeNames::y) {
-        m_y = AttributeParser::parse_coordinate(value).value();
+        m_y = AttributeParser::parse_coordinate(value).value_or(m_y);
     } else if (name == SVG::AttributeNames::dx) {
-        m_dx = AttributeParser::parse_coordinate(value).value();
+        m_dx = AttributeParser::parse_coordinate(value).value_or(m_dx);
     } else if (name == SVG::AttributeNames::dy) {
-        m_dy = AttributeParser::parse_coordinate(value).value();
+        m_dy = AttributeParser::parse_coordinate(value).value_or(m_dy);
     }
 }