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

Issue #52: Apostrophes break OS X client #53

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/DAV/plugins/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
};

/**
Expand Down
3 changes: 3 additions & 0 deletions lib/DAV/plugins/auth/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
15 changes: 13 additions & 2 deletions lib/DAV/property/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 += "<d:response>"
// Adding the baseurl to the beginning of the url
+ "<d:href>" + Util.escapeXml(encodeURI(handler.server.getBaseUri() + this.href)) + "</d:href>";
+ "<d:href>" + Util.escapeXml(href) + "</d:href>";

// The properties variable is an array containing properties, grouped by
// HTTP status
Expand Down