lib/roda/plugins/public.rb in roda-2.27.0 vs lib/roda/plugins/public.rb in roda-2.28.0
- old
+ new
@@ -19,14 +19,16 @@
#
# opts[:root] = '/path/to/app'
# plugin :public
# plugin :public, :root=>'static'
module Public
- NULL_BYTE = "\0".freeze
SPLIT = Regexp.union(*[File::SEPARATOR, File::ALT_SEPARATOR].compact)
PARSER = RUBY_VERSION >= '1.9' ? URI::DEFAULT_PARSER : URI
+ NULL_BYTE = "\0".freeze
+ RodaPlugins.deprecate_constant(self, :NULL_BYTE)
+
# Use options given to setup a Rack::File instance for serving files. Options:
# :default_mime :: The default mime type to use if the mime type is not recognized.
# :gzip :: Whether to serve already gzipped files with a .gz extension for clients
# supporting gzipped transfer encoding.
# :headers :: A hash of headers to use for statically served files
@@ -40,10 +42,10 @@
module RequestMethods
# Serve files from the public directory if the file exists and this is a GET request.
def public
if is_get?
path = PARSER.unescape(real_remaining_path)
- return if path.include?(NULL_BYTE)
+ return if path.include?("\0")
roda_opts = roda_class.opts
server = roda_opts[:public_server]
path = ::File.join(server.root, *public_path_segments(path))