BPackageInfo::Parser: Relax package/resolvable name rules

Now we allow any character but '-', '/', and whitespace.
This commit is contained in:
Ingo Weinhold 2013-04-19 16:04:27 +02:00
parent f16dbba442
commit cba60307b8

View File

@ -802,7 +802,7 @@ BPackageInfo::Parser::_Parse(BPackageInfo* packageInfo)
_ParseStringValue(&name, &namePos); _ParseStringValue(&name, &namePos);
int32 errorPos; int32 errorPos;
if (!_IsAlphaNumUnderscore(name, ".", &errorPos)) { if (!_IsValidResolvableName(name, &errorPos)) {
throw ParseError("invalid character in package name", throw ParseError("invalid character in package name",
namePos + errorPos); namePos + errorPos);
} }
@ -941,21 +941,14 @@ BPackageInfo::Parser::_IsAlphaNumUnderscore(const char* start, const char* end,
BPackageInfo::Parser::_IsValidResolvableName(const char* string, BPackageInfo::Parser::_IsValidResolvableName(const char* string,
int32* _errorPos) int32* _errorPos)
{ {
int32 errorPos; for (const char* c = string; *c != '\0'; c++) {
if (const char* colon = strchr(string, ':')) { if (*c == '-' || *c == '/' || isspace(*c)) {
if (_IsAlphaNumUnderscore(string, colon, ".", &errorPos)) {
if (_IsAlphaNumUnderscore(colon + 1, ".", &errorPos))
return true;
errorPos += colon + 1 - string;
}
} else {
if (_IsAlphaNumUnderscore(string, ".", &errorPos))
return true;
}
if (_errorPos != NULL) if (_errorPos != NULL)
*_errorPos = errorPos; *_errorPos = c - string;
return false; return false;
}
}
return true;
} }