Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-1080

JsonIO.cc should allow \u escape sequence in string

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.3
    • 1.7.0
    • c++
    • None
    • C++

    Description

      If an avro string contains a unicode escape sequence that begins with "\u" instead of "\U" an exception is thrown by the parser. The problematic code is at JsonIO.cc line 269.

      JsonParser::Token JsonParser::tryString()
      {
          sv.clear();
          for ( ; ;) {
              char ch = in_.read();
              if (ch == '"') {
                  return tkString;
              } else if (ch == '\\') {
                  ch = in_.read();
                  switch (ch) {
                  case '"':
                  case '\\':
                  case '/':
                      sv.push_back(ch);
                      continue;
                  case 'b':
                      sv.push_back('\b');
                      continue;
                  case 'f':
                      sv.push_back('\f');
                      continue;
                  case 'n':
                      sv.push_back('\n');
                      continue;
                  case 'r':
                      sv.push_back('\r');
                      continue;
                  case 't':
                      sv.push_back('\t');
                      continue;
                  case 'U':
                      {
                          unsigned int n = 0;
                          char e[4];
                          in_.readBytes(reinterpret_cast<uint8_t*>(e), 4);
                          for (int i = 0; i < 4; i++) {
                              n *= 16;
                              char c = e[i];
                              if (isdigit(c)) {
                                  n += c - '0';
                              } else if (c >= 'a' && c <= 'f') {
                                  n += c - 'a' + 10;
                              } else if (c >= 'A' && c <= 'F') {
                                  n += c - 'A' + 10;
                              } else {
                                  unexpected(c);
                              }
                          }
                          sv.push_back(n);
                      }
                      break;
                  default:
                      unexpected(ch);
                  }
              } else {
                  sv.push_back(ch);
              }
          }
      }
      

      Attachments

        1. AVRO-1080.patch
          0.7 kB
          Keh-Li Sheng

        Issue Links

          Activity

            People

              kehli Keh-Li Sheng
              kehli Keh-Li Sheng
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: