xiaokang commented on code in PR #21866:
URL: https://github.com/apache/doris/pull/21866#discussion_r1266042074


##########
be/src/vec/exec/format/json/new_json_reader.cpp:
##########
@@ -1475,15 +1476,18 @@ Status 
NewJsonReader::_simdjson_write_data_to_column(simdjson::ondemand::value&
         break;
     }
     default: {
-        auto str_view = simdjson::to_json_string(value).value();
         if (value.type() == simdjson::ondemand::json_type::string) {
+            uint8_t* unescape_buffer =
+                    
reinterpret_cast<uint8_t*>(&_simdjson_ondemand_unscape_padding_buffer[0]);
+            std::string_view unescaped_value =
+                    
_ondemand_json_parser->unescape(value.get_raw_json_string(), unescape_buffer);

Review Comment:
   If unescape_buffer is not big enough, will it cause buffer overflow?



##########
be/src/vec/exec/format/json/new_json_reader.cpp:
##########
@@ -1475,15 +1476,18 @@ Status 
NewJsonReader::_simdjson_write_data_to_column(simdjson::ondemand::value&
         break;
     }
     default: {
-        auto str_view = simdjson::to_json_string(value).value();
         if (value.type() == simdjson::ondemand::json_type::string) {
+            uint8_t* unescape_buffer =
+                    
reinterpret_cast<uint8_t*>(&_simdjson_ondemand_unscape_padding_buffer[0]);
+            std::string_view unescaped_value =
+                    
_ondemand_json_parser->unescape(value.get_raw_json_string(), unescape_buffer);
             nullable_column->get_null_map_data().push_back(0);
-            // trim
-            column_string->insert_data(str_view.data() + 1, str_view.length() 
- 2);
+            column_string->insert_data(unescaped_value.data(), 
unescaped_value.length());

Review Comment:
   If the table field is String but not JSON, is the unescaped string right?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to