NEW Remove the /m flags from String->match, replace regex, is match regex and friends - while this is backward-imcompatible, the flag severly limits functionality and can lead to security issues when used for input validation
This commit is contained in:
Родитель
b350a55d9c
Коммит
e548149a18
|
@ -171,7 +171,7 @@ module TDev.RT {
|
||||||
//? Indicates if the string matches a regular expression
|
//? Indicates if the string matches a regular expression
|
||||||
export function is_match_regex(self: string, pattern: string): boolean
|
export function is_match_regex(self: string, pattern: string): boolean
|
||||||
{
|
{
|
||||||
var rx = new RegExp(pattern, "gm");
|
var rx = new RegExp(pattern, "");
|
||||||
return rx.test(self);
|
return rx.test(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ module TDev.RT {
|
||||||
export function match(self: string, pattern: string): Collection<string>
|
export function match(self: string, pattern: string): Collection<string>
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
var rx = new RegExp(pattern, "m");
|
var rx = new RegExp(pattern, "");
|
||||||
var r = rx.exec(self);
|
var r = rx.exec(self);
|
||||||
if (!r)
|
if (!r)
|
||||||
return Collections.create_string_collection();
|
return Collections.create_string_collection();
|
||||||
|
@ -199,7 +199,7 @@ module TDev.RT {
|
||||||
export function matches(self: string, pattern: string): Collection<string>
|
export function matches(self: string, pattern: string): Collection<string>
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
var rx = new RegExp(pattern, "gm");
|
var rx = new RegExp(pattern, "g");
|
||||||
var r = self.match(rx);
|
var r = self.match(rx);
|
||||||
return Collection.mkStrings(r || []);
|
return Collection.mkStrings(r || []);
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ module TDev.RT {
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var rx = new RegExp(pattern, "gm");
|
var rx = new RegExp(pattern, "g");
|
||||||
return self.replace(rx, replace);
|
return self.replace(rx, replace);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
|
@ -240,7 +240,7 @@ module TDev.RT {
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var rx = new RegExp(pattern, "gm");
|
var rx = new RegExp(pattern, "g");
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче