lib/metadata/extract.rb
# Create a link to `filename' with a secure filename and yield it.
# Unlinks secure filename after yield returns.
#
# This is needed because of filenames like "-h".
#
# If the filename doesn't begin with a dash, passes it in
# double-quotes with double-quotes and dollar signs in
# filename escaped.
#
Create a link to `filename' with a secure filename and yield it.
Unlinks secure filename after yield returns.

This is needed because of filenames like "-h".

If the filename doesn't begin with a dash, passes it in
double-quotes with double-quotes and dollar signs in
filename escaped.
Create a link to ` filename ' with a secure filename and yield it . Unlinks secure filename after yield returns . This is needed because of filenames like " - h " . If the filename doesn ' t begin with a dash passes it in double - quotes with double - quotes and dollar signs in filename escaped .
def secure_filename(filename)
    require 'fileutils'
    if filename =~ /^-/
      dirname = File.dirname(File.expand_path(filename))
      tfn = "/tmp/" + temp_filename + (File.extname(filename) || "").
            gsub(/[^a-z0-9_.]/i, '_') 
      begin
        FileUtils.ln(filename, tfn)
      rescue
        FileUtils.cp(filename, tfn) 
      end
      yield(tfn)
    else 
      yield(%Q("#{filename.gsub(/[$"]/, "\\\\\\0")}"))
    end
  ensure
    File.unlink(tfn) if tfn and File.exist?(tfn)
  end
def secure_filename ( filename ) require 'fileutils' if filename =~ / ^- / dirname = File . dirname ( File . expand_path ( filename ) ) tfn = "/tmp/" + temp_filename + ( File . extname ( filename ) || "" ) . gsub ( / [^a-z0-9_.] /i , '_' ) begin FileUtils . ln ( filename , tfn ) rescue FileUtils . cp ( filename , tfn ) end yield ( tfn ) else yield ( %Q("#{filename.gsub(/[$"]/, "\\\\\\0")}") ) end ensure File . unlink ( tfn ) if tfn and File . exist? ( tfn ) end
Create a link to `filename' with a secure filename and yield it.
Create a link to ` filename ' with a secure filename and yield it .
# PAA RAA NOO IAA # different fs for /tmp # trust the filename to not blow up in our face
filename
<not_specific>