Remove parsing decimal numbers in StringToCode().

For ToUnicode mapping, bfrange or bfchar should only contain
hexadecimal numbers wrapped inside "<>".
This CL remove the steps for parsing decimal numbers in
CPDF_ToUnicodeMap::StringToCode().

Bug: pdfium:1422
Change-Id: Iac7d4e4b5e4380e0afb6aa08cef9792370f382f3
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/64150
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Hui Yingst <nigi@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_tounicodemap.cpp b/core/fpdfapi/font/cpdf_tounicodemap.cpp
index 2c9bb55..b275434 100644
--- a/core/fpdfapi/font/cpdf_tounicodemap.cpp
+++ b/core/fpdfapi/font/cpdf_tounicodemap.cpp
@@ -74,19 +74,13 @@
 // static
 uint32_t CPDF_ToUnicodeMap::StringToCode(ByteStringView str) {
   size_t len = str.GetLength();
-  if (len == 0)
+  if (len == 0 || str[0] != '<')
     return 0;
 
   uint32_t result = 0;
-  if (str[0] == '<') {
-    for (size_t i = 1; i < len && std::isxdigit(str[i]); ++i)
-      result = result * 16 + FXSYS_HexCharToInt(str.CharAt(i));
-    return result;
+  for (size_t i = 1; i < len && std::isxdigit(str[i]); ++i) {
+    result = result * 16 + FXSYS_HexCharToInt(str.CharAt(i));
   }
-
-  for (size_t i = 0; i < len && std::isdigit(str[i]); ++i)
-    result = result * 10 + FXSYS_DecimalCharToInt(str.CharAt(i));
-
   return result;
 }
 
diff --git a/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp b/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp
index 4a5dc25..bca94f3 100644
--- a/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp
+++ b/core/fpdfapi/font/cpdf_tounicodemap_unittest.cpp
@@ -8,11 +8,10 @@
 
 TEST(cpdf_tounicodemap, StringToCode) {
   EXPECT_EQ(0u, CPDF_ToUnicodeMap::StringToCode(""));
+  EXPECT_EQ(0u, CPDF_ToUnicodeMap::StringToCode("12"));
   EXPECT_EQ(194u, CPDF_ToUnicodeMap::StringToCode("<c2"));
   EXPECT_EQ(162u, CPDF_ToUnicodeMap::StringToCode("<A2"));
   EXPECT_EQ(2802u, CPDF_ToUnicodeMap::StringToCode("<Af2"));
-  EXPECT_EQ(12u, CPDF_ToUnicodeMap::StringToCode("12"));
-  EXPECT_EQ(128u, CPDF_ToUnicodeMap::StringToCode("128"));
 }
 
 TEST(cpdf_tounicodemap, StringToWideString) {