| Index: test/intl/date-format/property-override.js
|
| diff --git a/src/extensions/i18n/collator.h b/test/intl/date-format/property-override.js
|
| similarity index 55%
|
| copy from src/extensions/i18n/collator.h
|
| copy to test/intl/date-format/property-override.js
|
| index a3991b9ed244afad996cf5d547c17e077010ac60..a7b05751c0b3e192bd48e9c98e44c8626f86fc7f 100644
|
| --- a/src/extensions/i18n/collator.h
|
| +++ b/test/intl/date-format/property-override.js
|
| @@ -26,43 +26,46 @@
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| // limitations under the License.
|
|
|
| -#ifndef V8_EXTENSIONS_I18N_COLLATOR_H_
|
| -#define V8_EXTENSIONS_I18N_COLLATOR_H_
|
| -
|
| -#include "unicode/uversion.h"
|
| -#include "v8.h"
|
| +// Checks for security holes introduced by Object.property overrides.
|
| +// For example:
|
| +// Object.defineProperty(Array.prototype, 'locale', {
|
| +// set: function(value) {
|
| +// throw new Error('blah');
|
| +// },
|
| +// configurable: true,
|
| +// enumerable: false
|
| +// });
|
| +//
|
| +// would throw in case of (JS) x.locale = 'us' or (C++) x->Set('locale', 'us').
|
| +//
|
| +// Update both date-format.js and date-format.cc so they have the same list of
|
| +// properties.
|
|
|
| -namespace U_ICU_NAMESPACE {
|
| -class Collator;
|
| -class UnicodeString;
|
| +// First get supported properties.
|
| +// Some of the properties are optional, so we request them.
|
| +var properties = [];
|
| +var options = Intl.DateTimeFormat(
|
| + 'en-US', {weekday: 'short', era: 'short', year: 'numeric', month: 'short',
|
| + day: 'numeric', hour: 'numeric', minute: 'numeric',
|
| + second: 'numeric', timeZoneName: 'short'}).resolvedOptions();
|
| +for (var prop in options) {
|
| + if (options.hasOwnProperty(prop)) {
|
| + properties.push(prop);
|
| + }
|
| }
|
|
|
| -namespace v8_i18n {
|
| -
|
| -class Collator {
|
| - public:
|
| - static void JSCreateCollator(const v8::FunctionCallbackInfo<v8::Value>& args);
|
| -
|
| - // Helper methods for various bindings.
|
| -
|
| - // Unpacks collator object from corresponding JavaScript object.
|
| - static icu::Collator* UnpackCollator(v8::Handle<v8::Object> obj);
|
| -
|
| - // Release memory we allocated for the Collator once the JS object that
|
| - // holds the pointer gets garbage collected.
|
| - static void DeleteCollator(v8::Isolate* isolate,
|
| - v8::Persistent<v8::Object>* object,
|
| - void* param);
|
| +var expectedProperties = [
|
| + 'calendar', 'day', 'era', 'hour12', 'hour', 'locale',
|
| + 'minute', 'month', 'numberingSystem',
|
| + 'second', 'timeZone', 'timeZoneName', 'weekday', 'year'
|
| +];
|
|
|
| - // Compare two strings and returns -1, 0 and 1 depending on
|
| - // whether string1 is smaller than, equal to or larger than string2.
|
| - static void JSInternalCompare(
|
| - const v8::FunctionCallbackInfo<v8::Value>& args);
|
| +assertEquals(expectedProperties.length, properties.length);
|
|
|
| - private:
|
| - Collator() {}
|
| -};
|
| +properties.forEach(function(prop) {
|
| + assertFalse(expectedProperties.indexOf(prop) === -1);
|
| +});
|
|
|
| -} // namespace v8_i18n
|
| +taintProperties(properties);
|
|
|
| -#endif // V8_EXTENSIONS_I18N_COLLATOR_H_
|
| +var locale = Intl.DateTimeFormat().resolvedOptions().locale;
|
|
|