From a3f4e15b29e93a02e6dbde2b938777fd7524ec28 Mon Sep 17 00:00:00 2001 From: terminalchai Date: Sun, 12 Apr 2026 02:42:30 +0530 Subject: [PATCH] fix(regex): add missing 4th octet to email address IPv4 domain preset The 'Email address' preset in the Regular Expression operation was missing the 4th IPv4 octet in the bracketed address form, causing addresses like user@[1.2.3.4] to never match. The IPv4 bracket group ended after {3} repetitions of 'octet.': \\[(?:(?:(octet))\.){3}\\] This matches [1.2.3.] (a false positive) but not [1.2.3.4]. Fix: add the 4th octet group before the closing bracket, mirroring the correct regex already used in ExtractEmailAddresses.mjs: \\[(?:(?:(octet))\.){3}(?:(octet))\\] Closes #2150 --- src/core/operations/RegularExpression.mjs | 2 +- tests/operations/tests/Regex.mjs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/operations/RegularExpression.mjs b/src/core/operations/RegularExpression.mjs index 9ea17e83..660f250d 100644 --- a/src/core/operations/RegularExpression.mjs +++ b/src/core/operations/RegularExpression.mjs @@ -45,7 +45,7 @@ class RegularExpression extends Operation { }, { name: "Email address", - value: "(?:[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9](?:[\\u00A0-\\uD7FF\\uE000-\\uFFFF-a-z0-9-]*[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9])?\\.)+[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9](?:[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9-]*[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}\\])" + value: "(?:[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9](?:[\\u00A0-\\uD7FF\\uE000-\\uFFFF-a-z0-9-]*[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9])?\\.)+[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9](?:[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9-]*[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\])" }, { name: "URL", diff --git a/tests/operations/tests/Regex.mjs b/tests/operations/tests/Regex.mjs index a8697d46..60804801 100644 --- a/tests/operations/tests/Regex.mjs +++ b/tests/operations/tests/Regex.mjs @@ -55,5 +55,16 @@ TestRegister.addTests([ "args": ["User defined", "\\pS", true, true, false, false, true, false, "List matches"] } ], - } + }, + { + name: "Regex: Email address preset matches IPv4 domain", + input: "user@[1.2.3.4]\ntest@[192.168.0.1]\nno-match@[1.2.3.]", + expectedOutput: "user@[1.2.3.4]\ntest@[192.168.0.1]", + recipeConfig: [ + { + "op": "Regular expression", + "args": ["Email address", "", true, true, false, false, false, false, "List matches"] + } + ], + }, ]);