Adjust how AnnotationBorderStyle.setWidth
handles the input being a Name
(issue 10385)
In order to be consistent with the behaviour in Adobe Reader, the width will now always be set to zero when the input is a `Name`.
This commit is contained in:
parent
5a2bd9fc63
commit
66fccd860b
@ -485,7 +485,8 @@ class AnnotationBorderStyle {
|
|||||||
// Some corrupt PDF generators may provide the width as a `Name`,
|
// Some corrupt PDF generators may provide the width as a `Name`,
|
||||||
// rather than as a number (fixes issue 10385).
|
// rather than as a number (fixes issue 10385).
|
||||||
if (isName(width)) {
|
if (isName(width)) {
|
||||||
width = parseFloat(width.name);
|
this.width = 0; // This is consistent with the behaviour in Adobe Reader.
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (Number.isInteger(width)) {
|
if (Number.isInteger(width)) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
|
@ -236,12 +236,15 @@ describe('annotation', function() {
|
|||||||
expect(borderStyle.width).toEqual(1);
|
expect(borderStyle.width).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set/get a valid width, when the input is a `Name` (issue 10385)',
|
it('should set the width to zero, when the input is a `Name` (issue 10385)',
|
||||||
function() {
|
function() {
|
||||||
const borderStyle = new AnnotationBorderStyle();
|
const borderStyleZero = new AnnotationBorderStyle();
|
||||||
borderStyle.setWidth(Name.get('0'));
|
borderStyleZero.setWidth(Name.get('0'));
|
||||||
|
const borderStyleFive = new AnnotationBorderStyle();
|
||||||
|
borderStyleFive.setWidth(Name.get('5'));
|
||||||
|
|
||||||
expect(borderStyle.width).toEqual(0);
|
expect(borderStyleZero.width).toEqual(0);
|
||||||
|
expect(borderStyleFive.width).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set and get a valid style', function() {
|
it('should set and get a valid style', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user