Date: | 2013-07-05 20:00:46 (10 years 8 months ago) |
---|---|
Author: | Paul Cercueil |
Commit: | eb6329423193292c3c13e50c0b1f8cf56354b89a |
Message: | Don't call tolower() on the whole filenames, only on extensions tolower() will trigger an assertion failure in the case where the string contains UTF-8 codes. This is not a problem as only the file extension needs to be processed, and that one should contain only ASCII. |
Files: |
src/filelister.cpp (2 diffs) |
Change Details
src/filelister.cpp | ||
---|---|---|
83 | 83 | vector<string> vfilter; |
84 | 84 | split(vfilter, getFilter(), ","); |
85 | 85 | |
86 | string filepath, file, file_lowercase; | |
86 | string filepath, file; | |
87 | 87 | struct stat st; |
88 | 88 | struct dirent *dptr; |
89 | 89 | |
90 | 90 | while ((dptr = readdir(dirp))) { |
91 | 91 | file = dptr->d_name; |
92 | file_lowercase = file; | |
93 | std::transform(file_lowercase.begin(), file_lowercase.end(), file_lowercase.begin(), ::tolower); | |
94 | 92 | |
95 | 93 | if (file[0] == '.' && file != "..") |
96 | 94 | continue; |
... | ... | |
120 | 118 | continue; |
121 | 119 | |
122 | 120 | for (vector<string>::iterator it = vfilter.begin(); it != vfilter.end(); ++it) { |
123 | if (it->length() <= file.length()) { | |
124 | if (file_lowercase.compare(file.length() - it->length(), it->length(), *it) == 0) { | |
121 | if (it->length() < file.length()) { | |
122 | string file_lowercase = | |
123 | file.substr(file.length() - it->length()); | |
124 | if (file_lowercase[0] != '.') | |
125 | continue; | |
126 | ||
127 | /* XXX: This won't accept UTF-8 codes. | |
128 | * Thanksfully file extensions shouldn't contain any. */ | |
129 | transform(file_lowercase.begin(), file_lowercase.end(), | |
130 | file_lowercase.begin(), ::tolower); | |
131 | ||
132 | if (file_lowercase.compare(0, it->length(), *it) == 0) { | |
125 | 133 | files.push_back(file); |
126 | 134 | break; |
127 | 135 | } |
Branches:
install_locations
master
opkrun
packages