Skip to content

Commit

Permalink
Minor - Merge pull request wet-boew#9659 from polmih/scrubbing
Browse files Browse the repository at this point in the history
core - helpers: patch to cover encoded %2540 in email pattern

Minor - Core - findPotentialPII - Include URL encoded email pattern
  • Loading branch information
duboisp committed Sep 11, 2023
2 parents 2e1c03a + 213f328 commit 9aede44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ wb.findPotentialPII = function( str, scope, opts ) {
var oRegEx = {
digits: /\d(?:[\s\-\\.\\/]?\d){8,}(?!\d)/ig, //9digits or more pattern
passport: /\b[A-Za-z]{2}[\s\\.-]*?\d{6}\b/ig, //canadian nr passport pattern
email: /\b(?:[a-zA-Z0-9_\-\\.]+)(?:@|%40)(?:[a-zA-Z0-9_\-\\.]+)\.(?:[a-zA-Z]{2,5})\b/ig, //email pattern
email: /\b(?:[a-zA-Z0-9_\-\\.]+)(?:@|%40|%2540)(?:[a-zA-Z0-9_\-\\.]+)\.(?:[a-zA-Z]{2,5})\b/ig, //email pattern
postalCode: /\b[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d\b/ig, //postal code pattern
username: /(?:(username|user)[%20]?([:=]|(%EF%BC%9A))[^\s&]*)/ig,
password: /(?:(password|pass)[%20]?([:=]|(%EF%BC%9A))[^\s&]*)/ig
Expand Down
7 changes: 7 additions & 0 deletions src/core/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ describe( "findPotentialPII test suite", function() {
expect( wb.findPotentialPII( "email:1@example.com", true ) ).to.equal( "email:" );
} );

it( "should match email pattern", function() {
expect( wb.findPotentialPII( "email:1%40example.com", true ) ).to.equal( "email:" );
} );
it( "should match email pattern", function() {
expect( wb.findPotentialPII( "email:1%2540example.com", true ) ).to.equal( "email:" );
} );

it( "should match postal code pattern", function() {
expect( wb.findPotentialPII( "postal code:K2C3N2, postal code:K2C 3N2, postal code:K2C-3N2", true ) ).to.equal( "postal code:, postal code:, postal code:" );
} );
Expand Down

0 comments on commit 9aede44

Please sign in to comment.