]> granicus.if.org Git - icu/commitdiff
ICU-21335 Disallowed looking up resources by index in table-based resources.
authorRich Gillam <62772518+richgillam@users.noreply.github.com>
Wed, 10 Mar 2021 22:59:33 +0000 (14:59 -0800)
committerRich Gillam <62772518+richgillam@users.noreply.github.com>
Thu, 11 Mar 2021 00:51:51 +0000 (16:51 -0800)
icu4c/source/common/uresdata.cpp
icu4c/source/test/cintltst/creststn.c

index ae731e4544283bc22397a964a28facc6873b857d..9af081be408c1f686ac48edcfbb0aead635cda98 100644 (file)
@@ -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) {
index 8c9275fe3099891a17343edbebade3dd542dfcbc..ed044db21fe35b22e8d4a40c0436f02ca5834534 100644 (file)
@@ -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 */
     {