-
Notifications
You must be signed in to change notification settings - Fork 217
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
fix issue#59: add validation check during submission on WEB UI #71
Conversation
<div ng-messages="threadForm.networkName.$error"> | ||
<div ng-message="required">This is required.</div> | ||
<div ng-message="md-maxlength">The Netowork Name must be less than 16 characters long.</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Netowork Name must be no more than 16 characters!
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"less than" or "no more than"?
</div> | ||
</md-input-container> | ||
</div> | ||
|
||
<div layout="row"> | ||
<md-input-container flex="100"> | ||
<label>On-Mesh Prefix</label> | ||
<input required name="prefix" ng-model="thread.prefix"> | ||
<input required name="prefix" ng-model="thread.prefix" ng-pattern="/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1})/g"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this regex allows prefix length?
Is link-local address allowed as Thread prefix?
3e82653
to
3a05140
Compare
</div> | ||
</md-input-container> | ||
</div> | ||
|
||
<div layout="row"> | ||
<md-input-container flex="50"> | ||
<label>PAN ID</label> | ||
<input required name="panId" ng-model="thread.panId"> | ||
<input required name="panId" ng-model="thread.panId" ng-pattern="/^0x[0-9a-fA-F]{4}/g"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this regex allows 0x1234567890?
@@ -199,27 +201,31 @@ <h4 style="margin: 18px 12px 12px 24px">OT Border Router</h4> | |||
<div layout="row"> | |||
<md-input-container flex="50"> | |||
<label>Network Key</label> | |||
<input required name="networkKey" ng-model="thread.networkKey"> | |||
<input required minlength="32" maxlength="32" ng-pattern="/^[0-9a-fA-F]{32}/g" name="networkKey" ng-model="thread.networkKey"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
</div> | ||
</md-input-container> | ||
</div> | ||
|
||
<div layout="row"> | ||
<md-input-container flex="100"> | ||
<label>On-Mesh Prefix</label> | ||
<input required name="prefix" ng-model="thread.prefix"> | ||
<input required name="prefix" ng-model="thread.prefix" ng-pattern="/^((?!(fe80:)|(ff[01][0-9]:))([0-9a-fA-F]{1,4}:)(([0-9a-fA-F]{1,4}:){1,7}):((/[1-9][0-9]?){0,1}))$/"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this allows ff05::/64
@@ -212,7 +217,12 @@ | |||
}; | |||
|
|||
|
|||
$scope.showConfirm = function(ev) { | |||
$scope.showConfirm = function(ev, valid) { | |||
if (valid === false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if valid is boolean, is it simpler to use !valid here?
</div> | ||
</md-input-container> | ||
</div> | ||
<div layout="row"> | ||
<md-input-container flex="80"> | ||
<label>Prefix</label> | ||
<input required name="prefix" ng-model="thread.prefix"> | ||
<input required name="prefix" ng-model="thread.prefix" ng-pattern="/^((?!(fe80:)|(ff[01][0-9]:))([0-9a-fA-F]{1,4}:)(([0-9a-fA-F]{1,4}:){1,7}):((/[1-9][0-9]?){0,1}))$/"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
50d532f
to
aabead4
Compare
</div> | ||
</md-input-container> | ||
</div> | ||
|
||
<div layout="row"> | ||
<md-input-container flex="100"> | ||
<label>On-Mesh Prefix</label> | ||
<input required name="prefix" ng-model="thread.prefix"> | ||
<input required name="prefix" ng-model="thread.prefix" ng-pattern="/^((?!(fe80:)|(ff[0-9a-fA-F][0-9a-fA-F]:))([0-9a-fA-F]{1,4}:)(([0-9a-fA-F]{1,4}:){1,7}):((/[1-9][0-9]?){0,1}))$/"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this regex cannot work. Have you tried the following IPs?
FF01:0:0:0::/64
FE80:200:5aee::/64
fd11:22::/120
abcd::/64
2::/64
fd::1:0/120
I guess we can add regex modifier to perform case-insensitive matching. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
</div> | ||
</md-input-container> | ||
</div> | ||
<div layout="row"> | ||
<md-input-container flex="80"> | ||
<label>Prefix</label> | ||
<input required name="prefix" ng-model="thread.prefix"> | ||
<input required name="prefix" ng-model="thread.prefix" ng-pattern="/^((?!(fe80:)|(ff[0-9a-fA-F][0-9a-fA-F]:))([0-9a-fA-F]{1,4}:)(([0-9a-fA-F]{1,4}:){1,7}):((/[1-9][0-9]?){0,1}))$/"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the /
separator for prefix should be escaped.
1479f74
to
982a925
Compare
</div> | ||
</md-input-container> | ||
</div> | ||
<div layout="row"> | ||
<md-input-container flex="80"> | ||
<label>Prefix</label> | ||
<input required name="prefix" ng-model="thread.prefix"> | ||
<input required name="prefix" ng-model="thread.prefix" ng-pattern="/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\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*)(/(1([01][0-9]|2[0-8]))|/([0-9][0-9]?))?$/"> | ||
<div ng-messages="threadForm.prefix.$error"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the regular expression is composed by three parts:
?!([fF][eE]80:|[fF]{2}[0-9a-fA-F][0-9a-fA-F]:))
filters out link local address and multicast address.(\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*)
checks valid IPv6 address.(/(1([01][0-9]|2[0-8]))|/([0-9][0-9]?))?
checks the prefix length [0, 128].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should exclude ::
as well.
No description provided.