diff --git a/lib/DAV/plugins/auth.js b/lib/DAV/plugins/auth.js index 1cf37953..0d69b0fb 100644 --- a/lib/DAV/plugins/auth.js +++ b/lib/DAV/plugins/auth.js @@ -8,6 +8,7 @@ "use strict"; var jsDAV_ServerPlugin = require("./../plugin").jsDAV_ServerPlugin; +var jsDAV_Util_EventEmitter_PRIO_HIGH = require("./../util").EventEmitter.PRIO_HIGH; /** * This plugin provides Authentication for a WebDAV server. @@ -41,7 +42,7 @@ function jsDAV_Auth_Plugin(handler) { this.realm = null; this.initialize = function() { - this.handler.addEventListener("beforeMethod", this.beforeMethod.bind(this)); + this.handler.addEventListener("beforeMethod", this.beforeMethod.bind(this), jsDAV_Util_EventEmitter_PRIO_HIGH); }; /** diff --git a/lib/DAV/plugins/auth/file.js b/lib/DAV/plugins/auth/file.js index 73e52b38..f9de5c5d 100644 --- a/lib/DAV/plugins/auth/file.js +++ b/lib/DAV/plugins/auth/file.js @@ -43,6 +43,9 @@ function jsDAV_Auth_Backend_File(filename) { return cbloadfile(err); data.split("\n").forEach(function(line) { + if( '' == line ) /* ignore empty lines (including one at end of file) */ + cbloadfile(); + var parts = line.split(":"); if (line.length !== 3) cbloadfile(new Exc.jsDAV_Exception("Malformed htdigest file. Every line should contain 2 colons")); diff --git a/lib/DAV/property/response.js b/lib/DAV/property/response.js index c5ec3f31..06c9c8fc 100644 --- a/lib/DAV/property/response.js +++ b/lib/DAV/property/response.js @@ -51,9 +51,20 @@ exports.jsDAV_Property_Response = jsDAV_Property_Response; this.serialize = function(handler, dom) { var properties = this.responseProperties; + // Adding the baseurl to the beginning of the url + var href = handler.server.getBaseUri() + this.href; + href = href.split( '/' ); + href.forEach( function( value , key ) { + value = encodeURIComponent( value ); + value = value.replace( /[^a-zA-Z0-9%]/g , function( x ) { + return '%' + x.charCodeAt( 0 ).toString( 16 ); + } ); + href[ key ] = value; + } ); + href = href.join( '/' ); + dom += "" - // Adding the baseurl to the beginning of the url - + "" + Util.escapeXml(encodeURI(handler.server.getBaseUri() + this.href)) + ""; + + "" + Util.escapeXml(href) + ""; // The properties variable is an array containing properties, grouped by // HTTP status