https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292022-04-18T08:43:36ZRedmineRedmine - Defect #36969: EmailAddress regex matches invalid email addresseshttps://www.redmine.org/issues/36969?journal_id=1064222022-04-18T08:43:36ZGo MAEDA
<ul><li><strong>File</strong> <a href="/attachments/29090">36969.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/29090/36969.patch">36969.patch</a> added</li><li><strong>Category</strong> set to <i>Accounts / authentication</i></li><li><strong>Target version</strong> set to <i>5.1.0</i></li></ul><p>Setting the target version to 5.1.0.</p> Redmine - Defect #36969: EmailAddress regex matches invalid email addresseshttps://www.redmine.org/issues/36969?journal_id=1064522022-04-20T00:44:04ZGo MAEDA
<ul><li><strong>File</strong> <a href="/attachments/29117">36969-v2.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/29117/36969-v2.patch">36969-v2.patch</a> added</li></ul><p>Added a test to the patch.</p> Redmine - Defect #36969: EmailAddress regex matches invalid email addresseshttps://www.redmine.org/issues/36969?journal_id=1064622022-04-21T06:44:14ZMischa The Evil
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/106462/diff?detail_id=86468">diff</a>)</li></ul><p>This effectively changes <code>EmailAddress::EMAIL_REGEXP</code> from:<br /><pre><code class="ruby syntaxhl"><span class="sr">/\A([^@\s]+)@((?:[-a-z0-9]+\.)+(?:(?:xn--[-a-z0-9]+)|(?:[a-z]{2,})))\z/i</span>
</code></pre>to:<br /><pre><code class="ruby syntaxhl"><span class="sr">/\A[a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z/</span>
</code></pre>as <code>URI::MailTo::EMAIL_REGEXP</code> is defined as such in the Ruby source (<a class="external" href="https://github.com/ruby/ruby/blob/master/lib/uri/mailto.rb#L55">https://github.com/ruby/ruby/blob/master/lib/uri/mailto.rb#L55</a>).<br />This definition is effectively a Ruby port<sup><a href="#fn1">1</a></sup> of the JavaScript- and Perl-compatible regex example given in the <a href="https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address" class="external">HTML Living Standard</a>:<br /><pre><code class="js syntaxhl"><span class="o">/^</span><span class="p">[</span><span class="nx">a</span><span class="o">-</span><span class="nx">zA</span><span class="o">-</span><span class="nx">Z0</span><span class="o">-</span><span class="mi">9</span><span class="p">.</span><span class="o">!</span><span class="err">#</span><span class="nx">$</span><span class="o">%&</span><span class="dl">'</span><span class="s1">*+</span><span class="se">\</span><span class="s1">/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:</span><span class="se">\</span><span class="s1">.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
</span></code></pre></p>
Some quick notes on this change:
<ul>
<li>it fixes the cases of the first two email address examples, but <code>$test@example.com</code> still matches (and a little search will probably give more edge-cases);</li>
<li>the current custom regex includes capture groups while <code>URI::MailTo::EMAIL_REGEXP</code> doesn't (which changes the return value in some cases and thus may break plugins that depend on the current value of <code>EmailAddress::EMAIL_REGEXP</code>) e.g.:<br /><pre>
'test@example.com'.match(EmailAddress::EMAIL_REGEXP)
=> #<MatchData "test@example.com" 1:"test" 2:"example.com">
'test@example.com'.match(URI::MailTo::EMAIL_REGEXP)
=> #<MatchData "test@example.com">
</pre></li>
<li>given the previous note, this might be something that should be shipped in a major release (6.0.0) instead of a minor release (5.1.0).</li>
</ul>
<p id="fn1" class="footnote"><sup>1</sup> <a class="external" href="https://github.com/ruby/ruby/blob/master/lib/uri/mailto.rb#L54">https://github.com/ruby/ruby/blob/master/lib/uri/mailto.rb#L54</a></p> Redmine - Defect #36969: EmailAddress regex matches invalid email addresseshttps://www.redmine.org/issues/36969?journal_id=1066082022-05-05T07:08:04ZGo MAEDA
<ul></ul><p>Mischa The Evil wrote:</p>
<blockquote>
<ul>
<li>given the previous note, this might be something that should be shipped in a major release (6.0.0) instead of a minor release (5.1.0).</li>
</ul>
</blockquote>
<p>I don't think the change should be delivered in 6.0.0 instead of 5.1.0.</p>
<p>In Redmine, the change of version number from 5.0.0 to 5.1.0 is not a minor release but a major release. For example, when the version number changed from 3.0.0 to 3.1.0 or from 4.0.0 to 4.1.0, many new features were added and some plugins stopped working.</p>
<p>If this change cannot be delivered in 5.1.0 due to plugin compatibility, I am afraid that 5.1.0 can only include a few bug fixes and cannot include any new features.</p> Redmine - Defect #36969: EmailAddress regex matches invalid email addresseshttps://www.redmine.org/issues/36969?journal_id=1085322022-11-13T07:39:02ZGo MAEDA
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/37922">Defect #37922</a>: Valid email address is not allowed</i> added</li></ul> Redmine - Defect #36969: EmailAddress regex matches invalid email addresseshttps://www.redmine.org/issues/36969?journal_id=1109112023-10-07T03:43:09ZGo MAEDA
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Closed</i></li><li><strong>Assignee</strong> set to <i>Go MAEDA</i></li><li><strong>Resolution</strong> set to <i>Fixed</i></li></ul><p>Committed the patch in <a class="changeset" title="Replace custom EMAIL_REGEXP with URI::MailTo::EMAIL_REGEXP for more accurate email validation (#3..." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/22332">r22332</a>.</p> Redmine - Defect #36969: EmailAddress regex matches invalid email addresseshttps://www.redmine.org/issues/36969?journal_id=1127112024-02-02T00:25:49ZGo MAEDA
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/6088">Defect #6088</a>: eMail in uncommon formats considered invalid</i> added</li></ul>