Alona Kaplan has posted comments on this change.
Change subject: webadmin: Added validation to ProviderModel
......................................................................
Patch Set 5: (4 inline comments)
....................................................
File
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/UriAuthority.java
Line 4: import com.google.gwt.regexp.shared.RegExp;
Line 5:
Line 6: public class UriAuthority {
Line 7:
Line 8: private static final RegExp PATTERN_AUTHORITY =
RegExp.compile("^([^:]*)(?::(.*))?$", "i"); //$NON-NLS-1$ $NON-NLS-2$
I think that (.*) for the port part is not enough. You should at least check
that the port contains only digits.
Line 9:
Line 10: private boolean valid;
Line 11: private String host;
Line 12: private String port;
Line 20: }
Line 21: }
Line 22:
Line 23: @Override
Line 24: public String toString() {
If not valid you will get NPE cause host and port are null.
Line 25: String authority = new String();
Line 26: authority += host;
Line 27: if (!port.isEmpty()) {
Line 28: authority += ':' + port;
....................................................
File
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Uri.java
Line 34: }
Line 35: }
Line 36:
Line 37: @Override
Line 38: public String toString() {
In case the uri is not valid you"ll get NPE here.
Line 39: String uri = new String();
Line 40: if (!scheme.isEmpty()) {
Line 41: uri += scheme + "://"; //$NON-NLS-1$
Line 42: }
....................................................
File
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/validation/UrlValidation.java
Line 16: return res;
Line 17: }
Line 18:
Line 19: res =
getHostValidation().validate(uri.getAuthority().getHost());
Line 20: if (!uri.getScheme().equalsIgnoreCase(Uri.SCHEME_HTTP)) {
I understand that for your use case just 'http' is a valid schema. But
'UrlValidation' is name of general class and it should accept other schema's as
well. You can pass the valid schema's names as a parameter to the class.
Line 21: res.setSuccess(false);
Line 22: res.getReasons().add(getSchemeMessage());
Line 23: }
Line 24: return res;
--
To view, visit http://gerrit.ovirt.org/14695
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I754a7ce4e2aa719b0284d2dc0021822af2629b07
Gerrit-PatchSet: 5
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Lior Vernia <[email protected]>
Gerrit-Reviewer: Alona Kaplan <[email protected]>
Gerrit-Reviewer: Lior Vernia <[email protected]>
Gerrit-Reviewer: Oved Ourfali <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches