From a9be9b4fdbfd5a023395cc32dea59ad33b45f95c Mon Sep 17 00:00:00 2001 From: Max Neunhoeffer Date: Tue, 8 Mar 2016 11:20:52 +0100 Subject: [PATCH] Put in tests to check for existence of _from and _to in edges. --- arangod/V8Server/v8-collection.cpp | 2 +- arangod/VocBase/document-collection.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/arangod/V8Server/v8-collection.cpp b/arangod/V8Server/v8-collection.cpp index 8f7a1ca500..24d6fc28c3 100644 --- a/arangod/V8Server/v8-collection.cpp +++ b/arangod/V8Server/v8-collection.cpp @@ -1483,7 +1483,7 @@ static void ModifyVocbaseCol(TRI_voc_document_operation_e operation, auto workOnOneSearchVal = [&](v8::Local const searchVal) { std::string collName; if (!ExtractDocumentHandle(isolate, searchVal, collName, - updateBuilder, false)) { + updateBuilder, true)) { TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DOCUMENT_HANDLE_BAD); } }; diff --git a/arangod/VocBase/document-collection.cpp b/arangod/VocBase/document-collection.cpp index b5769ca0c6..5f710845b5 100644 --- a/arangod/VocBase/document-collection.cpp +++ b/arangod/VocBase/document-collection.cpp @@ -3305,6 +3305,18 @@ int TRI_document_collection_t::insert(Transaction* trx, VPackSlice const* slice, TRI_doc_mptr_t* mptr, OperationOptions& options, bool lock) { + + if (_info.type() == TRI_COL_TYPE_EDGE) { + VPackSlice s = slice->get(TRI_VOC_ATTRIBUTE_FROM); + if (!s.isString()) { + return TRI_ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE; + } + s = slice->get(TRI_VOC_ATTRIBUTE_TO); + if (!s.isString()) { + return TRI_ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE; + } + } + TRI_ASSERT(mptr != nullptr); mptr->setDataPtr(nullptr); @@ -3497,6 +3509,18 @@ int TRI_document_collection_t::replace(Transaction* trx, OperationOptions& options, bool lock, TRI_voc_rid_t& prevRev) { + + if (_info.type() == TRI_COL_TYPE_EDGE) { + VPackSlice s = newSlice.get(TRI_VOC_ATTRIBUTE_FROM); + if (!s.isString()) { + return TRI_ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE; + } + s = newSlice.get(TRI_VOC_ATTRIBUTE_TO); + if (!s.isString()) { + return TRI_ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE; + } + } + // initialize the result TRI_ASSERT(mptr != nullptr); mptr->setDataPtr(nullptr);