summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-09-16 11:13:27 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-09-16 11:13:27 -0700
commit7c8796eec96d41d4d719ff08aba9cc9dbc8e1352 (patch)
tree90a060d8e55273b7759e3915f75e731ded4d0a21
parentbcd06fce809642d1beb218bda3968d61c9dad433 (diff)
downloadchef-lcg/non-utf8-filenames-again.tar.gz
fix illegal utf-8 handling in tempfile nameslcg/non-utf8-filenames-again
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/file_content_management/tempfile.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/chef/file_content_management/tempfile.rb b/lib/chef/file_content_management/tempfile.rb
index eb9154c4b1..cf59a87996 100644
--- a/lib/chef/file_content_management/tempfile.rb
+++ b/lib/chef/file_content_management/tempfile.rb
@@ -73,7 +73,10 @@ class Chef
# this is similar to File.extname() but greedy about the extension (from the first dot, not the last dot)
def tempfile_extension
- File.basename(@new_resource.path)[/\..*/] || ""
+ # complexity here is due to supporting mangling non-UTF8 strings (e.g. latin-1 filenames with characters that are illegal in UTF-8)
+ b = File.basename(@new_resource.path)
+ i = b.index(".")
+ i.nil? ? "" : b[i..-1]
end
# Returns the possible directories for the tempfile to be created in.