JavaScript
This site contains weird, un(der)documented and security-relevant behaviour of JavaScript in general and various standard library functions.
RegExp.prototype.test()
The
test()method ofRegExpinstances executes a search with this regular expression for a match between a regular expression and a specified string. Returnstrueif there is a match;falseotherwise.
– From mdn.
When passed a non-string value, the given value will first be transformed to a string by its
type-specific ToString() abstract operation.
Take this sample code for instance.
/foo/.test(["foo", "bar", "baz"]);The given array ["foo", "bar", "baz"] will be transformed to a string like "foo,bar,baz".
Thus, the above code is equivalent to /foo/.test("foo,bar,baz");. The test() call will thus return true. This works
for any type with a ToString() abstract operation.