summaryrefslogtreecommitdiff
path: root/jstests/core/invalid_collation_locale.js
blob: d520aef59208900a129b63fbd50b88a5be2b542e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// This test is meant to reproduce SERVER-38840, where the ICU library crashes on Windows when
// attempting to parse an invalid ID-prefixed locale.
(function() {
"use strict";

const coll = db.invalid_collation_locale;
coll.drop();

// Locale's which start with "x" or "i" followed by a separator ("_" or "-") are considered
// ID-prefixed.
assert.commandFailedWithCode(
    db.createCollection(coll.getName(), {collation: {locale: "x_invalid"}}), ErrorCodes.BadValue);

assert.commandFailedWithCode(
    db.createCollection(coll.getName(), {collation: {locale: "X_invalid"}}), ErrorCodes.BadValue);

assert.commandFailedWithCode(
    db.createCollection(coll.getName(), {collation: {locale: "i-invalid"}}), ErrorCodes.BadValue);

assert.commandFailedWithCode(
    db.createCollection(coll.getName(), {collation: {locale: "I-invalid"}}), ErrorCodes.BadValue);

assert.commandFailedWithCode(
    db.createCollection(coll.getName(), {collation: {locale: "xx_invalid"}}), ErrorCodes.BadValue);
})();