Intentional trailing slashes should be left alone

This commit is contained in:
Andrew Naylor 2015-03-07 00:20:47 +00:00
Родитель 01a7ccddba
Коммит 466dc52492
2 изменённых файлов: 9 добавлений и 2 удалений

Просмотреть файл

@ -321,7 +321,8 @@ Notification.prototype.trim = function(length) {
return length - tooLong; return length - tooLong;
} }
escaped = this.truncateStringToLength(escaped, length - tooLong, encoding); escaped = this.truncateStringToLength(escaped, length - tooLong, encoding);
escaped = escaped.replace(/(\\+|\\u[0-9a-fA-F]{0,3})$/, ""); escaped = escaped.replace(/(\\u[0-9a-fA-F]{0,3})$/, "");
escaped = escaped.replace(/([^\\])\\$/, "$1");
var trimmed = Buffer.byteLength(escaped, encoding); var trimmed = Buffer.byteLength(escaped, encoding);
escaped = JSON.parse("\"" + escaped + "\""); escaped = JSON.parse("\"" + escaped + "\"");

Просмотреть файл

@ -143,9 +143,15 @@ describe("Notification", function() {
expect(note.alert).to.equal("\n\n"); expect(note.alert).to.equal("\n\n");
}); });
it("strips orphaned escape character", function () { it("leaves escaped escape character intact", function() {
note.alert = "test\\ message"; note.alert = "test\\ message";
note.trim(26); note.trim(26);
expect(note.alert).to.equal("test\\");
});
it("strips orphaned escape character", function () {
note.alert = "test\\ message";
note.trim(25);
expect(note.alert).to.equal("test"); expect(note.alert).to.equal("test");
}); });
}); });