normalize_path(path)
private
Normalizes a request path. Raises an exception if the path cannot be
normalized.
Show source
def normalize_path(path)
raise "abnormal path `#{path}'" if path[0] != //
ret = path.dup
ret.gsub!(%{/+}, '/')
while ret.sub!(%/\.(?:/|\Z)', '/'); end # /. => /
while ret.sub!(%/(?!\.\./)[^/]+/\.\.(?:/|\Z)', '/'); end
raise "abnormal path `#{path}'" if %{/\.\.(/|\Z)} =~ ret
ret
end