public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH pmg-gui] utils: escape `/` in regex for emails
@ 2023-11-30 12:44 Maximiliano Sandoval
  2024-02-23 18:11 ` Stoiko Ivanov
  0 siblings, 1 reply; 4+ messages in thread
From: Maximiliano Sandoval @ 2023-11-30 12:44 UTC (permalink / raw)
  To: pmg-devel

As it is, it is valid ECMA regex but invalid in many other dialects. We
escape it to make it valid in, say PCRE2.

Note that `/` marks the end of the regex [1], hence

    Some@example@oh\no@

is valid according to this regex if we do not escape `/`.

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
Fun fact: This was detected by xgettext while doing tests extracting
strings for translations.

 js/Utils.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/js/Utils.js b/js/Utils.js
index 7fa154e..8974cb9 100644
--- a/js/Utils.js
+++ b/js/Utils.js
@@ -903,7 +903,7 @@ Ext.define('PMG.Async', {
 Ext.apply(Ext.form.field.VTypes, {
     // matches the pmg-email-address in pmg-api
     PMGMail: function(v) {
-	return (/[^\s\\@]+@[^\s/\\@]+/).test(v);
+	return (/[^\s\\@]+@[^\s\/\\@]+/).test(v);
     },
     PMGMailText: gettext('Example') + ": user@example.com",
 });
-- 
2.39.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-26 12:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-30 12:44 [pmg-devel] [PATCH pmg-gui] utils: escape `/` in regex for emails Maximiliano Sandoval
2024-02-23 18:11 ` Stoiko Ivanov
2024-02-26  7:07   ` Dominik Csapak
2024-02-26 12:14     ` Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal