? ? Pending

User tests: Successful: Unsuccessful:

avatar Lab5-Switzerland
Lab5-Switzerland
4 Aug 2020

I simply put
new RegExp(" ... ")
around the email validation RegEx.
Reason : At least one very famous JS minifier which is in widespread use does stumble over this complex pattern, especially because they have problem recognizing them as such in the first place.
The simple 'wrap' makes it clearly and surely possible to identify the RegEx as such.
The Minifier I tested the most with and draw my conclusion from is JShrink from tedious ( https://github.com/tedious/JShrink ).

Pull Request for Issue # .

Summary of Changes

Testing Instructions

Actual result BEFORE applying this Pull Request

Expected result AFTER applying this Pull Request

Documentation Changes Required

avatar Lab5-Switzerland Lab5-Switzerland - open - 4 Aug 2020
avatar Lab5-Switzerland Lab5-Switzerland - change - 4 Aug 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 4 Aug 2020
Category JavaScript
avatar Quy
Quy - comment - 4 Aug 2020

Please merge #30275 & #30276 into one pull request. Thanks.

avatar Lab5-Switzerland
Lab5-Switzerland - comment - 4 Aug 2020

Please merge #30275 & #30276 into one pull request. Thanks.

I literally have no idea howto - total GitHub noob here.
Can you give me some "instructions for GitHub dummies" guide ?

avatar Quy
Quy - comment - 4 Aug 2020

Go to patch-1 branch (#30275): https://github.com/Lab5-Switzerland/joomla-cms/blob/patch-1/media/system/js/validate-uncompressed.js
Edit the file with changes from this PR and submit.

avatar C-Lodder
C-Lodder - comment - 5 Aug 2020

Please remove the double quotes you've used. This changes it to a constructor object and the regex will not work.

See example:

const str = 'test@hotmail.com';

const regex1 = new RegExp("/^[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])?)*$/");
const regex2 = new RegExp(/^[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])?)*$/);

console.log(regex1.test(str));
// expected output: true

console.log(regex2.test(str));
// expected output: true

Both expext true, however the constructor will return false

avatar Fedik
Fedik - comment - 5 Aug 2020

Both expext true, however the constructor will return false

it because the slash, not the double quotes:

const regex1 = new RegExp("^[a-z]*") // Correct
const regex2 = /^[a-z]*/ // Correct
const regex3 = new RegExp("/^[a-z]*/") // Wrong
avatar C-Lodder
C-Lodder - comment - 5 Aug 2020

@Fedik yeah, but you can keep the slashes and remove the quotes :)

avatar brianteeman
brianteeman - comment - 5 Aug 2020

As the only thing this PR does is to add the quotes removing them is the same as closing this PR ??

avatar Fedik
Fedik - comment - 5 Aug 2020

As the only thing this PR does is to add the quotes removing them is the same as closing this PR ??

very close , it still will have new RegExp( ... ) :)

well, I did not had such issue with minifier, for me it just a "cosmetic change" with new bugs :)

@Lab5-Switzerland one more problem with your changes, if you still want to use a double quote then you need to make sure that all back slash are escaped properly https://stackoverflow.com/a/37582643/1000711

avatar wilsonge wilsonge - change - 10 Aug 2020
Title
Update validate-uncompressed.js
Javascript Improvement for some minifiers
avatar wilsonge wilsonge - edited - 10 Aug 2020
avatar zero-24
zero-24 - comment - 12 Jun 2022

Will close here for now and not accept this change into the 3.10-dev branch. when there are still issues please check with J4 and do a fresh pr agsinst it.

avatar zero-24 zero-24 - change - 12 Jun 2022
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2022-06-12 17:56:46
Closed_By zero-24
Labels Added: ? ?
avatar zero-24 zero-24 - close - 12 Jun 2022

Add a Comment

Login with GitHub to post a comment