mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
[JS] Fix few errors around AFSpecial_Keystroke
- @cincodenada found some errors which are fixed in this patch; - it partially fixes issue #14306; - add some tests.
This commit is contained in:
parent
290cbc5232
commit
6369617e6f
3 changed files with 185 additions and 16 deletions
|
@ -433,11 +433,8 @@ class AForm {
|
|||
}
|
||||
|
||||
psf = this.AFMakeNumber(psf);
|
||||
if (psf === null) {
|
||||
throw new Error("Invalid psf in AFSpecial_Format");
|
||||
}
|
||||
|
||||
let formatStr = "";
|
||||
let formatStr;
|
||||
switch (psf) {
|
||||
case 0:
|
||||
formatStr = "99999";
|
||||
|
@ -486,7 +483,7 @@ class AForm {
|
|||
]);
|
||||
|
||||
function _checkValidity(_value, _cMask) {
|
||||
for (let i = 0, ii = value.length; i < ii; i++) {
|
||||
for (let i = 0, ii = _value.length; i < ii; i++) {
|
||||
const mask = _cMask.charAt(i);
|
||||
const char = _value.charAt(i);
|
||||
const checker = checkers.get(mask);
|
||||
|
@ -546,9 +543,6 @@ class AForm {
|
|||
}
|
||||
|
||||
psf = this.AFMakeNumber(psf);
|
||||
if (psf === null) {
|
||||
throw new Error("Invalid psf in AFSpecial_Keystroke");
|
||||
}
|
||||
|
||||
let formatStr;
|
||||
switch (psf) {
|
||||
|
@ -559,12 +553,8 @@ class AForm {
|
|||
formatStr = "99999-9999";
|
||||
break;
|
||||
case 2:
|
||||
const finalLen =
|
||||
event.value.length +
|
||||
event.change.length +
|
||||
event.selStart -
|
||||
event.selEnd;
|
||||
if (finalLen >= 8) {
|
||||
const value = this.AFMergeChange(event);
|
||||
if (value.length > 8 || value.startsWith("(")) {
|
||||
formatStr = "(999) 999-9999";
|
||||
} else {
|
||||
formatStr = "999-9999";
|
||||
|
|
|
@ -26,8 +26,8 @@ class Event {
|
|||
this.richChange = data.richChange || [];
|
||||
this.richChangeEx = data.richChangeEx || [];
|
||||
this.richValue = data.richValue || [];
|
||||
this.selEnd = data.selEnd || -1;
|
||||
this.selStart = data.selStart || -1;
|
||||
this.selEnd = data.selEnd ?? -1;
|
||||
this.selStart = data.selStart ?? -1;
|
||||
this.shift = data.shift || false;
|
||||
this.source = data.source || null;
|
||||
this.target = data.target || null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue