Better parsing of cssParsingErrors' offenders

This commit is contained in:
Gaël Métais
2015-05-04 16:16:33 +02:00
parent 5f1dd42559
commit ffee3b225f
+20 -7
View File
@@ -392,18 +392,31 @@ var policies = {
list: offenders.map(function(offender) {
var parts = /^(?:(?:<([^ \(]*)>|\[inline CSS\]) ?)?(?:\((((?! @ ).)*)(?: @ (\d+):(\d+))?\))?$/.exec(offender);
if (!parts) {
debug('cssParsingErrors offenders transform function error with "%s"', offender);
if (parts) {
return {
parseError: offender
error: parts[2],
file: parts[1] || null,
line: (parts[4] && parts[5]) ? parseInt(parts[4], 10) : null,
column: (parts[4] && parts[5]) ? parseInt(parts[5], 10) : null
};
}
// Try another syntax
parts = /^(.*) <(.*)> @ (\d+):(\d+)$/.exec(offender);
if (parts) {
return {
error: parts[1],
file: parts[2] || null,
line: parseInt(parts[3], 10),
column: parseInt(parts[4], 10)
}
}
debug('cssParsingErrors offenders transform function error with "%s"', offender);
return {
error: parts[2],
file: parts[1] || null,
line: (parts[4] && parts[5]) ? parseInt(parts[4], 10) : null,
column: (parts[4] && parts[5]) ? parseInt(parts[5], 10) : null
parseError: offender
};
})
};