app/models/hydra/access_controls/permission.rb in hydra-access-controls-12.0.0 vs app/models/hydra/access_controls/permission.rb in hydra-access-controls-12.0.1
- old
+ new
@@ -39,11 +39,11 @@
build_access(access) if access
super(attrs)
end
def agent_name
- URI.decode(parsed_agent.last)
+ decode(parsed_agent.last)
end
def update(*)
super.tap { reset }
end
@@ -78,11 +78,11 @@
raise ArgumentError, "Unknown agent type #{type.inspect}"
end
end
def build_agent_resource(prefix, name)
- [Agent.new(::RDF::URI.new("#{prefix}##{URI.encode(name)}"))]
+ [Agent.new(::RDF::URI.new("#{prefix}##{encode(name)}"))]
end
def build_access(access)
raise "Can't build access #{inspect}" unless access
self.mode = case access
@@ -93,8 +93,18 @@
when 'discover'
[Mode.new(Hydra::ACL.Discover)]
else
raise ArgumentError, "Unknown access #{access.inspect}"
end
+ end
+
+ private
+
+ def encode(str)
+ URI::RFC2396_Parser.new.escape(str)
+ end
+
+ def decode(str)
+ URI::RFC2396_Parser.new.unescape(str)
end
end
end