From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: Maximiliano Sandoval <m.sandoval@proxmox.com>
Cc: pmg-devel@lists.proxmox.com
Subject: Re: [pmg-devel] [PATCH pmg-gui] utils: escape `/` in regex for emails
Date: Fri, 23 Feb 2024 19:11:53 +0100 [thread overview]
Message-ID: <20240223191153.747c81e1@rosa.proxmox.com> (raw)
In-Reply-To: <20231130124416.176516-1-m.sandoval@proxmox.com>
Thomas and I talked shortly off-list - and I remembered that we
(Maximiliano and I) - also talked off-list quite a while ago...
sadly I forgot if we agreed on a v2, or if the issue was more with gettext?
just before this gets forgotten:
On Thu, 30 Nov 2023 13:44:16 +0100
Maximiliano Sandoval <m.sandoval@proxmox.com> wrote:
> 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);
as is this fails at eslint
from a quick search at developer.mozilla.org:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class:
```
This means /[/]/ is valid without needing to escape the /.
```
also:
```
These are syntax characters in regexes (/ is the delimiter of a regex literal), so they require escaping unless in a character class.
```
(and '/' is in a character-class)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape
> },
> PMGMailText: gettext('Example') + ": user@example.com",
> });
next prev parent reply other threads:[~2024-02-23 18:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-30 12:44 Maximiliano Sandoval
2024-02-23 18:11 ` Stoiko Ivanov [this message]
2024-02-26 7:07 ` Dominik Csapak
2024-02-26 12:14 ` Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240223191153.747c81e1@rosa.proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=m.sandoval@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox