Skip to content

Commit a7ec749

Browse files
committed
properly attach '.woff2' to filenames without suffix, don't use outfilename in woff2_info
1 parent 550cfa6 commit a7ec749

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

src/woff2_compress.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ int main(int argc, char **argv) {
2121
}
2222

2323
string filename(argv[1]);
24-
string outfilename = filename.substr(0, filename.find_last_of(".")) + ".woff2";
24+
int lastdot;
25+
string outfilename;
26+
if ((lastdot = filename.find_last_of(".")) > filename.find_last_of("/")) {
27+
outfilename = filename.substr(0, lastdot) + ".woff2";
28+
} else {
29+
outfilename = filename + ".woff2";
30+
}
31+
2532
fprintf(stdout, "Processing %s => %s\n",
2633
filename.c_str(), outfilename.c_str());
2734
string input = woff2::GetFileContent(filename);

src/woff2_decompress.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ int main(int argc, char **argv) {
2222
}
2323

2424
string filename(argv[1]);
25-
string outfilename = filename.substr(0, filename.find_last_of(".")) + ".ttf";
25+
int lastdot;
26+
string outfilename;
27+
if ((lastdot = filename.find_last_of(".")) > filename.find_last_of("/")) {
28+
outfilename = filename.substr(0, lastdot) + ".woff2";
29+
} else {
30+
outfilename = filename + ".woff2";
31+
}
2632

2733
// Note: update woff2_dec_fuzzer_new_entry.cc if this pattern changes.
2834
string input = woff2::GetFileContent(filename);

src/woff2_info.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ int main(int argc, char **argv) {
3737
}
3838

3939
string filename(argv[1]);
40-
string outfilename = filename.substr(0, filename.find_last_of(".")) + ".woff2";
41-
fprintf(stdout, "Processing %s => %s\n",
42-
filename.c_str(), outfilename.c_str());
40+
41+
fprintf(stdout, "Processing %s\n",
42+
filename.c_str());
4343
string input = woff2::GetFileContent(filename);
4444

4545
woff2::Buffer file(reinterpret_cast<const uint8_t*>(input.data()),

0 commit comments

Comments
 (0)