Skip to content

Commit

Permalink
Finish 3.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Jul 1, 2020
2 parents f92daa7 + a4072c3 commit 7e547c3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.3
3.1.4
14 changes: 7 additions & 7 deletions lib/rdf/model/uri.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding: utf-8
require 'uri'
require 'cgi'

module RDF
##
Expand Down Expand Up @@ -846,7 +846,7 @@ def parse(value)
parts[:user] = (user.dup.force_encoding(Encoding::UTF_8) if user)
parts[:password] = (password.dup.force_encoding(Encoding::UTF_8) if password)
parts[:host] = (host.dup.force_encoding(Encoding::UTF_8) if host)
parts[:port] = (URI.decode(port).to_i if port)
parts[:port] = (CGI.unescape(port).to_i if port)
parts[:path] = (path.to_s.dup.force_encoding(Encoding::UTF_8) unless path.empty?)
parts[:query] = (query[1..-1].dup.force_encoding(Encoding::UTF_8) if query)
parts[:fragment] = (fragment[1..-1].dup.force_encoding(Encoding::UTF_8) if fragment)
Expand Down Expand Up @@ -902,7 +902,7 @@ def user=(value)
# Normalized version of user
# @return [String]
def normalized_user
URI.encode(URI.decode(user), /[^#{IUNRESERVED}|#{SUB_DELIMS}]/) if user
URI.encode(CGI.unescape(user), /[^#{IUNRESERVED}|#{SUB_DELIMS}]/) if user
end

##
Expand All @@ -928,7 +928,7 @@ def password=(value)
# Normalized version of password
# @return [String]
def normalized_password
URI.encode(URI.decode(password), /[^#{IUNRESERVED}|#{SUB_DELIMS}]/) if password
URI.encode(CGI.unescape(password), /[^#{IUNRESERVED}|#{SUB_DELIMS}]/) if password
end

HOST_FROM_AUTHORITY_RE = /(?:[^@]+@)?([^:]+)(?::.*)?$/.freeze
Expand Down Expand Up @@ -1180,8 +1180,8 @@ def query_values(return_type=Hash)
inject(return_type == Hash ? {} : []) do |memo,kv|
k,v = kv.to_s.split('=', 2)
next if k.to_s.empty?
k = URI.decode(k)
v = URI.decode(v) if v
k = CGI.unescape(k)
v = CGI.unescape(v) if v
if return_type == Hash
case memo[k]
when nil then memo[k] = v
Expand Down Expand Up @@ -1293,7 +1293,7 @@ def self._load(data)
def normalize_segment(value, expr, downcase = false)
if value
value = value.dup.force_encoding(Encoding::UTF_8)
decoded = URI.decode(value)
decoded = CGI.unescape(value)
decoded.downcase! if downcase
URI.encode(decoded, /[^(?:#{expr})]/)
end
Expand Down
3 changes: 3 additions & 0 deletions lib/rdf/ntriples/reader.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# -*- encoding: utf-8 -*-

require 'strscan'

module RDF::NTriples
##
# N-Triples parser.
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/util/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ def log_depth(**options, &block)
# @return [void]
def logger_common(*args, level:, **options)
logger = self.logger(**options)
logger.log_statistics[level] = logger.log_statistics[level].to_i + 1
# Some older code uses integer level numbers
level = LOGGER_COMMON_LEVELS_REVERSE.fetch(level) if level.is_a?(Integer)
logger.log_statistics[level] = logger.log_statistics[level].to_i + 1
return if logger.level > LOGGER_COMMON_LEVELS.fetch(level)

depth = options.fetch(:depth, logger.log_depth)
Expand Down
3 changes: 2 additions & 1 deletion lib/rdf/vocab/writer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'rdf'
require 'rdf/vocabulary'
require 'cgi'

module RDF
##
Expand Down Expand Up @@ -84,7 +85,7 @@ def self.options
on: ["--extra URIEncodedJSON"],
description: "URI Encoded JSON representation of extra data"
) do |arg|
::JSON.parse(::URI.decode(arg)).inject({}) do |m1, (term, defs)|
::JSON.parse(::CGI.unescape(arg)).inject({}) do |m1, (term, defs)|
d1 = defs.inject({}) {|m, (k,v)| m.merge(k.to_sym => v)}
m1.merge(term.to_sym => d1)
end
Expand Down

0 comments on commit 7e547c3

Please sign in to comment.