Page MenuHomeSoftware Heritage

assets/utils: Fix git url validation when username contains underscore
ClosedPublic

Authored by anlambert on Nov 24 2020, 10:55 AM.

Details

Summary

If the username in a git repository URL contains an underscore, the isGitRepoUrl
function was not validating it.

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

This revision is now accepted and ready to land.Nov 24 2020, 10:59 AM

Build is green

Patch application report for D4570 (id=16227)

Rebasing onto 5c915825bd...

Current branch diff-target is up to date.
Changes applied before test
commit 8e5a45d3a61e5cea889c23fdd5f496462d0e5e60
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Tue Nov 24 10:51:51 2020 +0100

    assets/utils: Fix git url validation when username contains underscore

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/491/ for more details.

I am very confused about this function.

What is its purpose? What is endOfPattern supposed to match? Why is the domain inserted in the regexp? And the path matching seems to be missing a lot more characters than just underscores (eg. percents)

Oh and also, you wrote 9-_ in the range, which means all characters from 9 to _, that's probably not what you meant.

EDIT: actually, probably not since 9 is already part of a range, but that's confusing

Update regexp matching username (use \w instead of a-zA-Z0-9_)

I am very confused about this function.

What is its purpose? What is endOfPattern supposed to match? Why is the domain inserted in the regexp? And the path matching seems to be missing a lot more characters than just underscores (eg. percents)

Some context about its introduction: T1186, its purpose is to add extra checks on well known git repository URL scheme (github, gitlab, sourceforge, bitbucket).
I guess at the time, I inspired from this code.

Build is green

Patch application report for D4570 (id=16236)

Rebasing onto 5c915825bd...

Current branch diff-target is up to date.
Changes applied before test
commit 4feb7dab1a358b70b2aa6b81ebace49d15f2b8df
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Tue Nov 24 10:51:51 2020 +0100

    assets/utils: Fix git url validation when username contains underscore

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/492/ for more details.

This revision was landed with ongoing or failed builds.Nov 24 2020, 12:21 PM
This revision was automatically updated to reflect the committed changes.

Build is green

Patch application report for D4570 (id=16245)

Rebasing onto b7cb525fda...

Current branch diff-target is up to date.
Changes applied before test
commit 566de21143bc5892b82e116b58c80fc1dfc2d2bb
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Tue Nov 24 10:51:51 2020 +0100

    assets/utils: Fix git url validation when username contains underscore

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/494/ for more details.