Skip to content

Commit 2e0a34f

Browse files
committed
Loading an HTML with no script element should be an error, not an empty document.
1 parent 41a7a2e commit 2e0a34f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/json/ld/api.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,8 @@ def self.load_html(input, url:,
759759
# Find the first script with type application/ld+json.
760760
element = input.at_xpath("//script[starts-with(@type, 'application/ld+json;profile=#{profile}')]") if profile
761761
element ||= input.at_xpath("//script[starts-with(@type, 'application/ld+json')]")
762-
content = element ? element.inner_html : "[]"
762+
raise JSON::LD::JsonLdError::LoadingDocumentFailed, "No script tag found" unless element
763+
content = element.inner_html
763764
validate_input(content, url: url) if options[:validate]
764765
MultiJson.load(content, **options)
765766
end

0 commit comments

Comments
 (0)