Strip bidi control characters in filenames and elsewhere (#3208)
Passing unformatted = true to Item#getField() now returns a bidi control character-less result, and we use that in Reader#updateTitle() and getFileBaseNameFromItem() to prevent bidi control characters from showing up in filenames and window titles (the former everywhere, the latter on Windows only). We also strip bidi control characters in getValidFileName() to be extra safe.
This commit is contained in:
parent
f8b4d186a8
commit
676f820f87
7 changed files with 92 additions and 19 deletions
|
@ -35,6 +35,56 @@ describe("Zotero.Item", function () {
|
|||
]);
|
||||
assert.equal(item.getField('firstCreator'), "B");
|
||||
});
|
||||
|
||||
it("should return a multi-author firstCreator for an unsaved item", async function () {
|
||||
var item = createUnsavedDataObject('item');
|
||||
item.setCreators([
|
||||
{
|
||||
firstName: "A",
|
||||
lastName: "B",
|
||||
creatorType: "author"
|
||||
},
|
||||
{
|
||||
firstName: "C",
|
||||
lastName: "D",
|
||||
creatorType: "author"
|
||||
}
|
||||
]);
|
||||
assert.equal(
|
||||
item.getField('firstCreator'),
|
||||
Zotero.getString('general.andJoiner', ['\u2068B\u2069', '\u2068D\u2069'])
|
||||
);
|
||||
});
|
||||
|
||||
it("should strip bidi isolates from firstCreator when unformatted = true", async function () {
|
||||
var item = createUnsavedDataObject('item');
|
||||
item.setCreators([
|
||||
{
|
||||
firstName: "A",
|
||||
lastName: "B",
|
||||
creatorType: "author"
|
||||
},
|
||||
{
|
||||
firstName: "C",
|
||||
lastName: "D",
|
||||
creatorType: "author"
|
||||
}
|
||||
]);
|
||||
|
||||
// Test unsaved - uses getFirstCreatorFromData()'s omitBidiIsolates option
|
||||
assert.equal(
|
||||
item.getField('firstCreator', /* unformatted */ true),
|
||||
Zotero.getString('general.andJoiner', ['B', 'D'])
|
||||
);
|
||||
|
||||
await item.saveTx();
|
||||
|
||||
// Test saved - implemented in getField()
|
||||
assert.equal(
|
||||
item.getField('firstCreator', /* unformatted */ true),
|
||||
Zotero.getString('general.andJoiner', ['B', 'D'])
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#setField", function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue