Puppet Function: simplib::safe_filename
- Defined in:
- functions/safe_filename.pp
- Function type:
- Puppet Language
Overview
Convert a string into a filename that is ‘path safe’
The goal is to ensure that files do not contain characters that may accidentally turn into deeper path entries or invalid filenames.
This is not perfect but should be sufficient for most cases and can be improved over time.
20 21 22 23 24 25 26 |
# File 'functions/safe_filename.pp', line 20
function simplib::safe_filename (
String $input,
String[1] $pattern = '[\\\\/?*:|"<>]',
String[1] $replacement = '__'
) {
regsubst($input, $pattern, $replacement, 'G')
}
|