Skip to content

Commit

Permalink
Throw copy exception on invalid utf8 string
Browse files Browse the repository at this point in the history
  • Loading branch information
acquamarin committed Oct 13, 2023
1 parent faa5f98 commit da30e53
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/processor/operator/persistent/reader/csv/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "processor/operator/persistent/reader/csv/parallel_csv_reader.h"
#include "processor/operator/persistent/reader/csv/serial_csv_reader.h"
#include "storage/store/table_copy_utils.h"
#include "utf8proc_wrapper.h"

using namespace kuzu::common;

Expand Down Expand Up @@ -340,6 +341,9 @@ void copyStringToVector(ValueVector* vector, uint64_t rowToAdd, std::string_view
vector, rowToAdd, reinterpret_cast<char*>(blobBuffer.get()), blobLen);
} break;
case LogicalTypeID::STRING: {
if (!utf8proc::Utf8Proc::isValid(strVal.data(), strVal.length())) {
throw common::CopyException{"Invalid UTF8-encoded string."};
}
StringVector::addString(vector, rowToAdd, strVal.data(), strVal.length());
} break;
case LogicalTypeID::DATE: {
Expand Down

0 comments on commit da30e53

Please sign in to comment.