Browse Source

Do not require a final semi-colon while parsing the 'style' attribute.

Michael Ragazzon 5 years ago
parent
commit
2f65848c5b
2 changed files with 14 additions and 4 deletions
  1. 12 3
      Source/Core/StyleSheetParser.cpp
  2. 2 1
      Source/Core/StyleSheetParser.h

+ 12 - 3
Source/Core/StyleSheetParser.cpp

@@ -502,13 +502,13 @@ bool StyleSheetParser::ParseProperties(PropertyDictionary& parsed_properties, co
 	StreamMemory stream_owner((const byte*)properties.c_str(), properties.size());
 	StreamMemory stream_owner((const byte*)properties.c_str(), properties.size());
 	stream = &stream_owner;
 	stream = &stream_owner;
 	PropertySpecificationParser parser(parsed_properties, StyleSheetSpecification::GetPropertySpecification());
 	PropertySpecificationParser parser(parsed_properties, StyleSheetSpecification::GetPropertySpecification());
-	bool success = ReadProperties(parser);
+	bool success = ReadProperties(parser, false);
 	stream = nullptr;
 	stream = nullptr;
 	return success;
 	return success;
 }
 }
 
 
 
 
-bool StyleSheetParser::ReadProperties(AbstractPropertyParser& property_parser)
+bool StyleSheetParser::ReadProperties(AbstractPropertyParser& property_parser, bool require_end_semicolon)
 {
 {
 	String name;
 	String name;
 	String value;
 	String value;
@@ -591,8 +591,17 @@ bool StyleSheetParser::ReadProperties(AbstractPropertyParser& property_parser)
 		previous_character = character;
 		previous_character = character;
 	}
 	}
 
 
-	if (!name.empty() || !value.empty())
+	if (!require_end_semicolon && !name.empty() && !value.empty())
+	{
+		value = StringUtilities::StripWhitespace(value);
+
+		if (!property_parser.Parse(name, value))
+			Log::Message(Log::LT_WARNING, "Syntax error parsing property declaration '%s: %s;' in %s: %d.", name.c_str(), value.c_str(), stream_file_name.c_str(), line_number);
+	}
+	else if (!name.empty() || !value.empty())
+	{
 		Log::Message(Log::LT_WARNING, "Invalid property declaration '%s':'%s' at %s:%d", name.c_str(), value.c_str(), stream_file_name.c_str(), line_number);
 		Log::Message(Log::LT_WARNING, "Invalid property declaration '%s':'%s' at %s:%d", name.c_str(), value.c_str(), stream_file_name.c_str(), line_number);
+	}
 	
 	
 	return true;
 	return true;
 }
 }

+ 2 - 1
Source/Core/StyleSheetParser.h

@@ -81,7 +81,8 @@ private:
 	// Parses properties from the parse buffer into the dictionary
 	// Parses properties from the parse buffer into the dictionary
 	// @param properties The dictionary to store the properties in
 	// @param properties The dictionary to store the properties in
 	// @param property_specification The specification used to parse the values. Normally the default stylesheet specification, but not for e.g. all at-rules such as decorators.
 	// @param property_specification The specification used to parse the values. Normally the default stylesheet specification, but not for e.g. all at-rules such as decorators.
-	bool ReadProperties(AbstractPropertyParser& property_parser);
+	// @param require_end_semicolon True to require a ';' character after the final property.
+	bool ReadProperties(AbstractPropertyParser& property_parser, bool require_end_semicolon = true);
 
 
 	// Import properties into the stylesheet node
 	// Import properties into the stylesheet node
 	// @param node Node to import into
 	// @param node Node to import into