diff --git a/Binary_JData_Specification.md b/Binary_JData_Specification.md index ba95511..b8df510 100644 --- a/Binary_JData_Specification.md +++ b/Binary_JData_Specification.md @@ -455,14 +455,27 @@ array or object) are considered to be of that singular _type_ and, as a result, _type_ markers are omitted for each value within the container. This can be thought of as providing the ability to create a strongly-typed container in BJData. +A major different between BJData and UBJSON is that the _type_ in a BJData +strongly-typed container is limited to **non-zero-fixed-length data types**, therefore, +only integers (`i,U,I,u,l,m,L,M`), floating-point numbers (`h,d,D`) and char (`C`) +are qualified. All zero-length types (`T,F,Z,N`), variable-length types(`S, H`) +and container types (`[,{`) shall not be used in an optimized _type_ header. +This restriction is set to reduce the security risks due to potentials of +buffer-overflow attacks using [zero-length markers](https://github.com/nlohmann/json/issues/2793), +hampered readability and dimished benefit using variable/container +types in an optimized format. + +The requirements for _type_ are + +- If a _type_ is specified, it **must** be one of `i,U,I,u,l,m,L,M,h,d,D,C`. - If a _type_ is specified, it **must** be done so before a _count_. - If a _type_ is specified, a _count_ **must** be specified as well. (Otherwise it is impossible to tell when a container is ending, e.g. did you just parse *]* or the `int8` value of 93?) -#### Example (string type): +#### Example (uint8 type): ``` -[$][S] +[$][U] ``` --- @@ -579,25 +592,6 @@ Optimized with both _type_ and _count_ // No end marker since a count was specified. ``` ---- -### Special case: Marker-only types (`null`, `no-op` & Boolean) -If using both _count_ and _type_ optimizations, the marker itself represents the -value, thus saving repetition (since these types do not have a payload). -Additional examples are: - -Strongly-typed array of type `true` (Boolean) and with a _count_ of 512: -``` -[[][$][T][#][I][512] -``` - -Strongly-typed object of type `null` and with a _count_ of 3: -``` -[{][$][Z][#][i][3] - [i][4][name] // name only, no value specified. - [i][8][password] - [i][5][email] -``` - Recommended File Specifiers ------------------------------ diff --git a/README.md b/README.md index acb1299..b5465b9 100644 --- a/README.md +++ b/README.md @@ -40,13 +40,13 @@ draft of this file specification, including question, report a bug, provide a feature request, or simply propose general discussions. Please use URLs or keywords to link your discussion to a specific line/section/topic in the document. -- [Write short comments on Request for Comments (RFC) commits](https://github.com/NeuroJSON/bjdata/commit/3f12e5ddaf75863ed9a69714dbd00e1258660118) +- [Write short comments on Request for Comments (RFC) commits](https://github.com/NeuroJSON/bjdata/commit/679e92e45aa3ceae9fb5bc74e469ca8cf504be41) - A milestone version of the specification will be associated with an RFC (Request for comments) commit (where the entire file is removed and re-added so that every line appears in such commit). One can write short comments as well as post replies on this RFC page. - The latest stable release is **[Version 1 Draft 2](https://github.com/NeuroJSON/bjdata/tree/Draft_2)**. Please use - [this link](https://github.com/NeuroJSON/bjdata/commit/3f12e5ddaf75863ed9a69714dbd00e1258660118) to comment. + [this link](https://github.com/NeuroJSON/bjdata/commit/679e92e45aa3ceae9fb5bc74e469ca8cf504be41) to comment. - To add a comment, you need to first register a github account, and then browse the above RFC page. When hovering your cursor over each line, a "plus" icon is displayed, clicking it will allow one to comment on a