Skip to content

Commit 1a2f614

Browse files
committed
Don't cache base from remote context.
1 parent 84beced commit 1a2f614

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/json/ld/context.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,9 @@ def parse(local_context,
627627
# Parse stand-alone
628628
ctx = Context.new(**options)
629629
ctx.context_base = context.to_s
630-
ctx.parse(remote_doc.document['@context'], remote_contexts: remote_contexts.dup)
630+
ctx = ctx.parse(remote_doc.document['@context'], remote_contexts: remote_contexts.dup)
631+
ctx.base = nil
632+
ctx
631633
end
632634
rescue JsonLdError::LoadingDocumentFailed => e
633635
#log_debug("parse") {"Failed to retrieve @context from remote document at #{context_no_base.context_base.inspect}: #{e.message}"}
@@ -671,10 +673,12 @@ def parse(local_context,
671673
requestProfile: 'http://www.w3.org/ns/json-ld#context',
672674
base: nil)
673675
context_opts.delete(:headers)
676+
# FIXME: should cache this, but ContextCache is for parsed contexts
674677
JSON::LD::API.loadRemoteDocument(source, **context_opts) do |remote_doc|
675678
# Dereference source. If the dereferenced document has no top-level JSON object with an @context member, an invalid remote context has been detected and processing is aborted; otherwise, set context to the value of that member.
676679
raise JsonLdError::InvalidRemoteContext, "#{source}" unless remote_doc.document.is_a?(Hash) && remote_doc.document.has_key?('@context')
677680
import_context = remote_doc.document['@context']
681+
import_context.delete('@base')
678682
raise JsonLdError::InvalidRemoteContext, "#{import_context.to_json} must be an object" unless import_context.is_a?(Hash)
679683
raise JsonLdError::InvalidContextEntry, "#{import_context.to_json} must not include @import entry" if import_context.has_key?('@import')
680684
context.delete(key)

0 commit comments

Comments
 (0)