Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate host/path pattern in Create Route form #2383

Merged
merged 3 commits into from
Jun 19, 2018
Merged

Conversation

irfanhabib
Copy link
Contributor

No description provided.

@cfdreddbot
Copy link

Hey irfanhabib!

Thanks for submitting this pull request! I'm here to inform the recipients of the pull request that you and the commit authors have already signed the CLA.

@irfanhabib irfanhabib self-assigned this Jun 15, 2018
Copy link
Contributor

@nwmac nwmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regex needs more work

@@ -33,7 +33,8 @@ import { Domain } from '../../../../store/types/domain.types';
import { Route, RouteMode } from '../../../../store/types/route.types';
import { ApplicationService } from '../../application.service';


const hostPattern = '(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])';
const pathPattern = `^((\/)${hostPattern}?(\/)*)*$`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the path allows more chars than the host. See: https://tools.ietf.org/html/rfc3986#section-3.3 and https://tools.ietf.org/html/rfc3986#appendix-A

@@ -33,7 +33,8 @@ import { Domain } from '../../../../store/types/domain.types';
import { Route, RouteMode } from '../../../../store/types/route.types';
import { ApplicationService } from '../../application.service';


const hostPattern = '(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct - it allows lots of invalid characters - e.g. /, % etc - see: https://en.wikipedia.org/wiki/Hostname for a simple explanation of what is allowed.

@nwmac nwmac added the needs attention This PR needs attention label Jun 18, 2018
@codecov
Copy link

codecov bot commented Jun 18, 2018

Codecov Report

Merging #2383 into v2-master will increase coverage by <.01%.
The diff coverage is 100%.

@@              Coverage Diff              @@
##           v2-master    #2383      +/-   ##
=============================================
+ Coverage      71.04%   71.05%   +<.01%     
=============================================
  Files            583      583              
  Lines          24452    24454       +2     
  Branches        5483     5483              
=============================================
+ Hits           17373    17375       +2     
  Misses          7079     7079

@irfanhabib irfanhabib added comments-addressed and removed needs attention This PR needs attention labels Jun 18, 2018
Copy link
Contributor

@nwmac nwmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nwmac nwmac merged commit 962fcdb into v2-master Jun 19, 2018
@nwmac nwmac deleted the route-sanity-checking branch June 19, 2018 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants