Skip to content

Commit b9e6f2a

Browse files
committed
Remove strict validation of localized keys in desktop file reader
Making the validation more strict broke pretty much all AppImage builds on the KDE binary factory. Also, the validation is a nonfunctional aspect in this case, even if the keys' syntax was broken, the code could continue. I don't recall why I opted to implement such validation there in the first place. The strict validation should most likely be an optional feature (e.g., provided in a method validate()), but not done in the constructor.
1 parent 695d4c8 commit b9e6f2a

File tree

1 file changed

+4
-44
lines changed

1 file changed

+4
-44
lines changed

src/desktopfilereader.cpp

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -136,50 +136,10 @@ namespace linuxdeploy {
136136
throw ParseError(errorPrefix + "invalid ] position");
137137
}
138138

139-
// splitting the locale into the three parts (of which only one is mandatory) is easier
140-
// if we strip the surrounding brackets first
141-
const auto innerPart = entryLocale.substr(1, entryLocale.size() - 2);
142-
143-
// will be std::string::npos if necessary
144-
const auto stopPosition = innerPart.find('.');
145-
const auto atPosition = innerPart.find('@');
146-
147-
auto langCountry = innerPart.substr(0, std::min(stopPosition, atPosition));
148-
std::string encoding, modifier;
149-
150-
if (stopPosition != std::string::npos) {
151-
encoding = innerPart.substr(stopPosition + 1, atPosition);
152-
}
153-
if (atPosition != std::string::npos) {
154-
modifier = innerPart.substr(atPosition + 1);
155-
}
156-
157-
// lang_COUNTRY may only contain A-Za-z- characters according to specification
158-
for (const char c : langCountry) {
159-
if (!(
160-
(c >= 'A' && c <= 'Z') ||
161-
(c >= 'a' && c <= 'z') ||
162-
(c == '_')
163-
)) {
164-
throw ParseError("Locale " + key + " lang_COUNTRY contains invalid character " + std::string{c});
165-
}
166-
}
167-
168-
// encoding may only contain A-Za-z- characters according to specification
169-
// if the encoding is empty, this loop is a no-op
170-
for (const char c : encoding) {
171-
if (!(
172-
(c >= 'A' && c <= 'Z') ||
173-
(c >= 'a' && c <= 'z') ||
174-
(c >= '0' && c <= '9') ||
175-
(c == '-')
176-
)) {
177-
throw ParseError("Locale " + key + " encoding contains invalid character " + std::string{c});
178-
}
179-
}
180-
181-
// TODO: test modifier properly
182-
(void) modifier;
139+
// the syntax within the brackets is not tested by intention, as some KDE apps
140+
// use a locale called "x-test" for some reason
141+
// strict validation of the locale part broke all AppImage builds on the KDE binary
142+
// factory
183143
}
184144

185145
auto& section = sections[currentSectionName];

0 commit comments

Comments
 (0)