@@ -85,25 +85,26 @@ <h1 id="internalproperties">Internal properties</h1>
8585
8686< p > Internal strings cannot be created from Ecmascript code using the default
8787built-ins alone. However, application code can easily add such a binding
88- using the C API (this must be considered in sandboxing) .</ p >
88+ using the C API which must be considered in sandboxing.</ p >
8989
9090< p > There's no special access control for internal properties: if user code has
9191access to the property name (string), it can read/write the property value.
92- Any code with the ability to create or use buffers can potentially create an
93- internal string by converting a buffer into a string. However, standard Ecmascript
94- code with no access to buffer values or ability to create them cannot create internal
95- strings (or any invalid UTF-8 strings in general) . When sandboxing, ensure that
96- the sandboxed code has no access to the < code > Duktape </ code > built-in or any
97- buffer values .</ p >
92+ The default Ecmascript built-ins don't provide a way of creating an internal
93+ string: buffer-to-string coercions always involve an encoding such as UTF-8
94+ which will reject or replace invalid byte sequences. However, C code can
95+ easily create internal strings. When sandboxing, ensure that custom C bindings
96+ don't accidentally provide a mechanism to create internal strings by e.g.
97+ converting a buffer as-is to a string .</ p >
9898
99- < p > As a concrete example, the internal value of a < code > Date</ code > can be
100- accessed as follows:</ p >
99+ < p > As a concrete example the internal value of a < code > Date</ code > instance
100+ can be accessed as follows:</ p >
101101< pre class ="ecmascript-code ">
102- // Print the internal timestamp of a Date instance. User code should NEVER
103- // actually do this because the internal properties may change between
104- // versions in an arbitrary manner!
102+ // Print the internal timestamp of a Date instance. Assumes a hypothetical
103+ // rawBufferToString() custom C binding which takes an input buffer and pushes
104+ // the bytes as-is as a string using duk_push_lstring(), thus creating an
105+ // internal string.
105106
106- var key = Duktape.dec('hex', 'ff56616c7565'); // \xFFValue
107+ var key = rawBufferToString( Duktape.dec('hex', 'ff56616c7565') ); // \xFFValue
107108var dt = new Date(123456);
108109print('internal value is:', dt[key]); // prints 123456
109110</ pre >
0 commit comments