PROPFIND error
This commit is contained in:
parent
5e058f5aef
commit
7429f418f5
@ -39,14 +39,14 @@ module Dav4rack
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.unescape_path(path)
|
def self.unescape_path(path)
|
||||||
path = path.dup
|
p = path.dup
|
||||||
path.force_encoding 'UTF-8'
|
p.force_encoding 'UTF-8'
|
||||||
Addressable::URI.unencode path
|
Addressable::URI.unencode p
|
||||||
end
|
end
|
||||||
|
|
||||||
# Namespace being used within XML document
|
# Namespace being used within XML document
|
||||||
def ns(wanted_uri = XmlElements::DAV_NAMESPACE)
|
def ns(wanted_uri = XmlElements::DAV_NAMESPACE)
|
||||||
if (root = document&.root) && (ns_defs = root.namespace_definitions) && !ns_defs.empty?
|
if document && (root = document.root) && (ns_defs = root.namespace_definitions) && !ns_defs.empty?
|
||||||
result = ns_defs.detect { |nd| nd.href == wanted_uri } || ns_defs.first
|
result = ns_defs.detect { |nd| nd.href == wanted_uri } || ns_defs.first
|
||||||
result = result.prefix.nil? ? 'xmlns' : result.prefix.to_s
|
result = result.prefix.nil? ? 'xmlns' : result.prefix.to_s
|
||||||
result += ':' unless result.empty?
|
result += ':' unless result.empty?
|
||||||
@ -63,23 +63,27 @@ module Dav4rack
|
|||||||
|
|
||||||
# Requested depth
|
# Requested depth
|
||||||
def depth
|
def depth
|
||||||
d = get_header('HTTP_DEPTH')
|
@depth ||= if (d = get_header('HTTP_DEPTH')) && %w[0 1].include?(d)
|
||||||
@depth ||=
|
d.to_i
|
||||||
if %w[0 1].include?(d)
|
elsif infinity_depth_allowed?
|
||||||
d
|
:infinity
|
||||||
elsif infinity_depth_allowed?
|
else
|
||||||
'infinity'
|
1
|
||||||
else
|
end
|
||||||
'1'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Destination header
|
# Destination header
|
||||||
def destination
|
def destination
|
||||||
@destination ||=
|
unless @destination
|
||||||
if (h = get_header('HTTP_DESTINATION'))
|
h = get_header('HTTP_DESTINATION')
|
||||||
DestinationHeader.new Dav4rack::Uri.new(h, script_name: script_name)
|
@destination = DestinationHeader.new Dav4rack::Uri.new(h, script_name: script_name) if h
|
||||||
end
|
end
|
||||||
|
@destination
|
||||||
|
end
|
||||||
|
|
||||||
|
# Overwrite is allowed
|
||||||
|
def overwrite?
|
||||||
|
get_header('HTTP_OVERWRITE').to_s.casecmp('F').zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
# content_length as a Fixnum (nil if the header is unset / empty)
|
# content_length as a Fixnum (nil if the header is unset / empty)
|
||||||
@ -124,7 +128,7 @@ module Dav4rack
|
|||||||
path = ::File.expand_path path
|
path = ::File.expand_path path
|
||||||
path << '/' if collection && !path.end_with?('/')
|
path << '/' if collection && !path.end_with?('/')
|
||||||
# remove a drive letter in Windows
|
# remove a drive letter in Windows
|
||||||
path.gsub %r{^([^/]*)/}, '/'
|
path.gsub(%r{^([^/]*)/}, '/')
|
||||||
end
|
end
|
||||||
|
|
||||||
REDIRECTABLE_CLIENTS = [
|
REDIRECTABLE_CLIENTS = [
|
||||||
@ -137,17 +141,8 @@ module Dav4rack
|
|||||||
# TODO: Allow this to be dynamic so users can add regexes to match if they know of a client
|
# TODO: Allow this to be dynamic so users can add regexes to match if they know of a client
|
||||||
# that can be supported that is not listed.
|
# that can be supported that is not listed.
|
||||||
def client_allows_redirect?
|
def client_allows_redirect?
|
||||||
REDIRECTABLE_CLIENTS.any? { |re| user_agent =~ re }
|
ua = user_agent
|
||||||
end
|
REDIRECTABLE_CLIENTS.any? { |re| ua =~ re }
|
||||||
|
|
||||||
MS_CLIENTS = [
|
|
||||||
/microsoft-webdav/i,
|
|
||||||
/microsoft office/i
|
|
||||||
].freeze
|
|
||||||
|
|
||||||
# Basic user agent testing for MS authored client
|
|
||||||
def ms_client?
|
|
||||||
MS_CLIENTS.any? { |re| user_agent =~ re }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_header(name)
|
def get_header(name)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user