From a7ec74931292f2e960f4eeac0cbd5d205d3a8c9c Mon Sep 17 00:00:00 2001 From: "Rainer M. Canavan" Date: Wed, 11 Oct 2017 15:11:42 +0200 Subject: [PATCH] properly attach '.woff2' to filenames without suffix, don't use outfilename in woff2_info --- src/woff2_compress.cc | 9 ++++++++- src/woff2_decompress.cc | 8 +++++++- src/woff2_info.cc | 6 +++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/woff2_compress.cc b/src/woff2_compress.cc index 80e3108..7bf6a96 100644 --- a/src/woff2_compress.cc +++ b/src/woff2_compress.cc @@ -21,7 +21,14 @@ int main(int argc, char **argv) { } string filename(argv[1]); - string outfilename = filename.substr(0, filename.find_last_of(".")) + ".woff2"; + int lastdot; + string outfilename; + if ((lastdot = filename.find_last_of(".")) > filename.find_last_of("/")) { + outfilename = filename.substr(0, lastdot) + ".woff2"; + } else { + outfilename = filename + ".woff2"; + } + fprintf(stdout, "Processing %s => %s\n", filename.c_str(), outfilename.c_str()); string input = woff2::GetFileContent(filename); diff --git a/src/woff2_decompress.cc b/src/woff2_decompress.cc index de088b9..0cf2b3f 100644 --- a/src/woff2_decompress.cc +++ b/src/woff2_decompress.cc @@ -22,7 +22,13 @@ int main(int argc, char **argv) { } string filename(argv[1]); - string outfilename = filename.substr(0, filename.find_last_of(".")) + ".ttf"; + int lastdot; + string outfilename; + if ((lastdot = filename.find_last_of(".")) > filename.find_last_of("/")) { + outfilename = filename.substr(0, lastdot) + ".woff2"; + } else { + outfilename = filename + ".woff2"; + } // Note: update woff2_dec_fuzzer_new_entry.cc if this pattern changes. string input = woff2::GetFileContent(filename); diff --git a/src/woff2_info.cc b/src/woff2_info.cc index 2b51adc..6490c91 100644 --- a/src/woff2_info.cc +++ b/src/woff2_info.cc @@ -37,9 +37,9 @@ int main(int argc, char **argv) { } string filename(argv[1]); - string outfilename = filename.substr(0, filename.find_last_of(".")) + ".woff2"; - fprintf(stdout, "Processing %s => %s\n", - filename.c_str(), outfilename.c_str()); + + fprintf(stdout, "Processing %s\n", + filename.c_str()); string input = woff2::GetFileContent(filename); woff2::Buffer file(reinterpret_cast(input.data()),