From e548149a18acc399c294f4474b7dca1b4d587256 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Sun, 26 Jul 2015 13:57:27 -0700 Subject: [PATCH] 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 --- lib/String.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/String.ts b/lib/String.ts index d4850601..cc2d11b6 100644 --- a/lib/String.ts +++ b/lib/String.ts @@ -171,7 +171,7 @@ module TDev.RT { //? Indicates if the string matches a regular expression 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); } @@ -183,7 +183,7 @@ module TDev.RT { export function match(self: string, pattern: string): Collection { try { - var rx = new RegExp(pattern, "m"); + var rx = new RegExp(pattern, ""); var r = rx.exec(self); if (!r) return Collections.create_string_collection(); @@ -199,7 +199,7 @@ module TDev.RT { export function matches(self: string, pattern: string): Collection { try { - var rx = new RegExp(pattern, "gm"); + var rx = new RegExp(pattern, "g"); var r = self.match(rx); return Collection.mkStrings(r || []); } @@ -225,7 +225,7 @@ module TDev.RT { { try { - var rx = new RegExp(pattern, "gm"); + var rx = new RegExp(pattern, "g"); return self.replace(rx, replace); } catch (e) @@ -240,7 +240,7 @@ module TDev.RT { { try { - var rx = new RegExp(pattern, "gm"); + var rx = new RegExp(pattern, "g"); } catch (e) {