mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 15:42:14 +00:00
ICU-21335 Disallowed looking up resources by index in table-based resources.
This commit is contained in:
parent
63b9a8aea8
commit
e43c4e5f1b
2 changed files with 3 additions and 15 deletions
|
@ -960,14 +960,6 @@ res_findResource(const ResourceData *pResData, Resource r, char** path, const ch
|
|||
if(URES_IS_TABLE(type)) {
|
||||
*key = pathP;
|
||||
t2 = res_getTableItemByKey(pResData, t1, &indexR, key);
|
||||
if(t2 == RES_BOGUS) {
|
||||
/* if we fail to get the resource by key, maybe we got an index */
|
||||
indexR = uprv_strtol(pathP, &closeIndex, 10);
|
||||
if(indexR >= 0 && *closeIndex == 0 && (*pathP != '0' || closeIndex - pathP == 1)) {
|
||||
/* if we indeed have an index, try to get the item by index */
|
||||
t2 = res_getTableItemByIndex(pResData, t1, indexR, key);
|
||||
} // else t2 is already RES_BOGUS
|
||||
}
|
||||
} else if(URES_IS_ARRAY(type)) {
|
||||
indexR = uprv_strtol(pathP, &closeIndex, 10);
|
||||
if(indexR >= 0 && *closeIndex == 0) {
|
||||
|
|
|
@ -2319,16 +2319,12 @@ static void TestResourceLevelAliasing(void) {
|
|||
|
||||
/* test indexed aliasing */
|
||||
|
||||
tb = ures_getByKey(aliasB, "zoneTests", tb, &status);
|
||||
tb = ures_getByKey(tb, "zoneAlias2", tb, &status);
|
||||
string = tres_getString(tb, -1, NULL, &strLen, &status);
|
||||
|
||||
en = ures_findResource("/ICUDATA-zone/en/zoneStrings/3/0", en, &status);
|
||||
sequence = tres_getString(en, -1, NULL, &seqLen, &status);
|
||||
|
||||
if(U_FAILURE(status) || seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
|
||||
log_err("Referencing alias didn't get the right string (5)\n");
|
||||
if(status != U_MISSING_RESOURCE_ERROR) {
|
||||
log_err("Index lookup in a table resource didn't get U_MISSING_RESOURCE_ERROR!\n");
|
||||
}
|
||||
status = U_ZERO_ERROR;
|
||||
}
|
||||
/* test getting aliased string by index */
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue