mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 10:52:48 -07:00
check template UTF8 validity before parsing
This commit is contained in:
@@ -107,6 +107,11 @@ module Liquid
|
||||
# Returns self for easy chaining
|
||||
def parse(source, options = {})
|
||||
parse_context = configure_options(options)
|
||||
|
||||
unless source.valid_encoding?
|
||||
raise SyntaxError, parse_context.locale.t("errors.syntax.invalid_template_encoding")
|
||||
end
|
||||
|
||||
tokenizer = parse_context.new_tokenizer(source, start_line_number: @line_numbers && 1)
|
||||
@root = Document.parse(tokenizer, parse_context)
|
||||
self
|
||||
|
||||
Reference in New Issue
Block a user