Fix a minor matching issue for google docs

This commit is contained in:
Calvin Montgomery 2014-08-08 23:27:54 -07:00
parent 4f7ec228d3
commit 9ff23622a0
2 changed files with 18 additions and 2 deletions

View File

@ -707,7 +707,7 @@ var Getters = {
* Match [[anything]] and ignore whitespace
* Fix 2014-08-07: [^] matches \r\n, . doesn't.
*/
var m = res.match(/(\[\s*\[[^\[][^]*?\]\s*\])/);
var m = res.match(/\[(\[\s*\[[^\[][^]*?\]\s*\])/);
try {
var propertyList = JSON.parse(m[1]);
var data = {};
@ -751,7 +751,6 @@ var Getters = {
callback(null, new Media(id, title, seconds, "gd", { gpdirect: direct }));
} catch (e) {
console.error(e);
return callback("Failed to parse Google Docs output", null);
}
});

17
lib/safe-regex.js Normal file
View File

@ -0,0 +1,17 @@
var starHeightSafe = require("safe-regex");
var parse = require("ret");
module.exports = function (re) {
if (re.source) {
re = re.source;
}
if (!starHeightSafe(re)) {
return false;
}
var node = parse(re);
console.log(require('util').inspect(node.stack));
console.log(parse.types);
return true;
};