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

Unterminated character class #153

Open
redrockzee opened this issue Aug 24, 2016 · 1 comment
Open

Unterminated character class #153

redrockzee opened this issue Aug 24, 2016 · 1 comment

Comments

@redrockzee
Copy link

This is my file server startup.
:
var jsDAV = require("jsDAV");
jsDAV.debugMode = true;
var jsDAV_Locks_Backend_FS = require("jsDAV/lib/DAV/plugins/locks/fs");

jsDAV.createServer({
node: "./webdav",
locksBackend: jsDAV_Locks_Backend_FS.new("./webdav")
}, 8889);

I get this error when performing a GET on a docx file on Windows. Is the Windows path the problem?

[error] [SyntaxError: Invalid regular expression: /[]+$/: Unterminated character class]
SyntaxError: Invalid regular expression: /[]+$/: Unterminated character class
at new RegExp (native)
at Object.exports.rtrim (c:\devel\dov\node_modules\jsDAV\lib\shared\util.js:114:14)
at Object.module.exports.jsDAV_Tree.extend.getRealPath (c:\devel\dov\node_modules\jsDAV\lib\DAV\backends\fs\tree.js:62:31)
at Object.module.exports.jsDAV_Tree.extend.getNodeForPath (c:\devel\dov\node_modules\jsDAV\lib\DAV\backends\fs\tree.js:41:29)
at __dirname.getNodeForPath (c:\devel\dov\node_modules\jsDAV\lib\DAV\handler.js:328:26)
at __dirname.getAllowedMethods (c:\devel\dov\node_modules\jsDAV\lib\DAV\handler.js:1199:14)
at __dirname.httpOptions (c:\devel\dov\node_modules\jsDAV\lib\DAV\handler.js:374:14)
at c:\devel\dov\node_modules\jsDAV\lib\DAV\handler.js:250:81
at c:\devel\dov\node_modules\jsDAV\lib\shared\asyncEvents.js:82:13
at handler (c:\devel\dov\node_modules\asyncjs\lib\async.js:371:33)

This code throws the error:
/**

  • Removes trailing whitespace
  • version: 1107.2516
  • from: http://phpjs.org/functions/rtrim
  • original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  • example 1: rtrim('    Kevin van Zonneveld    ');
    
  • returns 1: '    Kevin van Zonneveld'
    
    _/
    exports.rtrim = function(str, charlist) {
    charlist = !charlist ? " \s\u00A0" : (charlist+"").replace(/([.?/_{}+$^:])/g, "$1");
    var re = new RegExp("[" + charlist + "]+$", "g");
    return (str+"").replace(re, "");
    };
@redrockzee
Copy link
Author

redrockzee commented Aug 24, 2016

I fixed this by replacing this function so that it trims both / and \ rather than just using Path.sep. Path.sep contains \ on Windows and is not escaped properly for regular expressions in rtrim().

In tree.js:
getRealPath: function(publicPath) {
//return Path.join(Util.rtrim(this.basePath, Path.sep), Util.trim(publicPath, Path.sep));
return Path.join(Util.rtrim(this.basePath, '/\'), Util.trim(publicPath, '/\'));
},

redrockzee pushed a commit to dov-forks/jsDAV that referenced this issue Aug 24, 2016
SwadicalRag added a commit to SwadicalRag/jsDAV that referenced this issue Feb 25, 2017
Fix for Issue mikedeboer#153 "Unterminated character class"
redrockzee pushed a commit to dov-forks/jsDAV that referenced this issue Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant