Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloud-filelink.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Viguier <guillaume@viguierjust.com>2017-07-10 12:37:39 +0300
committerGuillaume Viguier <guillaume@viguierjust.com>2017-07-10 12:37:39 +0300
commit8d49d498dd10684e5468a0683c33dfe8bcee2755 (patch)
tree1f004e567d91a14ba5f95e3a5c1698fd9d2d3924
parent7b4a70a3654594c07c7198d9f49758c38901ff61 (diff)
#29 - error message when server URL missing scheme
-rw-r--r--src/components/nsNextcloud.js19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/components/nsNextcloud.js b/src/components/nsNextcloud.js
index f016e06..b4334cb 100644
--- a/src/components/nsNextcloud.js
+++ b/src/components/nsNextcloud.js
@@ -51,12 +51,16 @@ function wwwFormUrlEncode (aStr) {
.replace(/\@/g, '%40');
}
+function validURL(value) {
+ return /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(value);
+}
+
/**
* Our Nextcloud Provider
*/
function Nextcloud () {
- //this.log = Log4Moz.getConfiguredLogger("Nextcloud", Log4Moz.Level.Info, Log4Moz.Level.Debug,
- // Log4Moz.Level.Debug);
+ // this.log = Log4Moz.getConfiguredLogger("Nextcloud", Log4Moz.Level.Info, Log4Moz.Level.Debug,
+ // Log4Moz.Level.Debug);
this.log = Log4Moz.getConfiguredLogger("Nextcloud");
}
@@ -379,7 +383,7 @@ Nextcloud.prototype = {
],
2);
- if (authPrompter.promptPassword(
+ if (validURL(serverUrl) && authPrompter.promptPassword(
this.displayName,
promptString,
serverUrl,
@@ -411,8 +415,15 @@ Nextcloud.prototype = {
logon: function nsNc_logon (successCallback, failureCallback, aWithUI) {
this.log.info("Logging in, aWithUI = " + aWithUI);
- if (this._password == undefined || !this._password)
+ if (this._password == undefined || !this._password) {
this._password = this.getPassword(this._userName, !aWithUI);
+ }
+
+ if (this._password == "") {
+ this.log.error('Could not retrieve password');
+ this._loggedIn = false;
+ failureCallback();
+ }
this.log.info("Sending login information...");