10000 issue #1409: Document values with null character truncated with 2.6.2… · orakle/arangodb@e5dbc98 · GitHub
[go: up one dir, main page]

Skip to content

Commit e5dbc98

Browse files
author
Jan Steemann
committed
issue arangodb#1409: Document values with null character truncated with 2.6.2 on Windows
1 parent 7302df0 commit e5dbc98

File tree

7 files changed

+247
-144
lines changed

7 files changed

+247
-144
lines changed

Documentation/Books/Users/Glossary/README.mdpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ Foxx applications are also organized in database-specific directories inside the
6161
```
6262
apps/ # the instance's application directory
6363
system/ # system applications (can be ignored)
64-
databases/ # sub-directory containing database-specific applications
64+
_db/ # sub-directory containing database-specific applications
6565
<database-name>/ # sub-directory for a single database
66-
<app-name> # sub-directory for a single application
67-
<app-name> # sub-directory for a single application
66+
<mountpoint>/APP # sub-directory for a single application
67+
<mountpoint>/APP # sub-directory for a single application
6868
<database-name>/ # sub-directory for another database
69-
<app-name> # sub-directory for a single application
69+
<mountpoint>/APP # sub-directory for a single application
7070
```
7171

7272
!SUBSECTION Document

Documentation/Books/Users/NamingConventions/AttributeNames.mdpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
Users can pick attribute names for document attributes as desired, provided the
44
following attribute naming constraints are not violated:
5+
56
- Attribute names starting with an underscore are considered to be system
67
attributes for ArangoDB's internal use. Such attribute names are already used
78
by ArangoDB for special purposes:
@@ -41,6 +42,8 @@ following attribute naming constraints are not violated:
4142
length is variable and depends on the number and data types of attributes
4243
used.
4344
* Attribute names are case-sensitive.
45+
* Attribute names should not include the NUL byte (`\u0000`), as names will be
46+
truncated at the first NUL byte.
4447
* Attributes with empty names (the empty string) are removed from the document
4548
when saving it.
4649

js/common/tests/shell-attributes.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,52 @@ function AttributesSuite () {
439439
assertEqual(value["@language"], doc["@language"]);
440440
assertEqual(value["@value"], doc["@value"]);
441441
});
442+
},
443+
444+
////////////////////////////////////////////////////////////////////////////////
445+
/// @brief test attribute names containing NULL bytes
446+
////////////////////////////////////////////////////////////////////////////////
447+
448+
testNullBytes : function () {
449+
var doc = { "abc" : "foo\u0001bar\u0000baz", "def" : "\u0000test\u0000test", "123" : "abc\u0000" };
450+
451+
var d1 = c.save(doc);
452+
var d2 = c.document(d1._id);
453+
454+
assertEqual("foo\u0001bar\u0000baz", d2.abc);
455+
assertEqual("\u0000test\u0000test", d2.def);
456+
assertEqual("abc\u0000", d2["123"]);
457+
458+
var docs = c.toArray();
459+
assertEqual("foo\u0001bar\u0000baz", docs[0].abc);
460+
assertEqual("\u0000test\u0000test", docs[0].def);
461+
assertEqual("abc\u0000", docs[0]["123"]);
462+
463+
var result = db._query("FOR doc IN @@collection RETURN doc", { "@collection" : c.name() }).toArray();
464+
assertEqual("foo\u0001bar\u0000baz", result[0].abc);
465+
assertEqual("\u0000test\u0000test", result[0].def);
466+
assertEqual("abc\u0000", result[0]["123"]);
467+
468+
469+
// now shape documents
470+
require("internal").wal.flush(true, true);
471+
wait(3, false);
472+
473+
var d3 = c.document(d1._id);
474+
475+
assertEqual("foo\u0001bar\u0000baz", d3.abc);
476+
assertEqual("\u0000test\u0000test", d3.def);
477+
assertEqual("abc\u0000", d3["123"]);
478+
479+
docs = c.toArray();
480+
assertEqual("foo\u0001bar\u0000baz", docs[0].abc);
481+
assertEqual("\u0000test\u0000test", docs[0].def);
482+
assertEqual("abc\u0000", docs[0]["123"]);
483+
484+
result = db._query("FOR doc IN @@collection RETURN doc", { "@collection" : c.name() }).toArray();
485+
assertEqual("foo\u0001bar\u0000baz", result[0].abc);
486+
assertEqual("\u0000test\u0000test", result[0].def);
487+
assertEqual("abc\u0000", result[0]["123"]);
442488
}
443489

444490
};

lib/Basics/json.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static int StringifyJson (TRI_memory_zone_t* zone,
101101

102102
if (object->_value._string.length > 0) {
103103
// optimisation for the empty string
104-
res = TRI_AppendJsonEncodedStringStringBuffer(buffer, object->_value._string.data, false);
104+
res = TRI_AppendJsonEncodedStringStringBuffer(buffer, object->_value._string.data, object->_value._string.length - 1, false);
105105

106106
if (res != TRI_ERROR_NO_ERROR) {
107107
return TRI_ERROR_OUT_OF_MEMORY;

0 commit comments

Comments
 (0)
0