File tree 3 files changed +27
-1
lines changed
3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -901,7 +901,7 @@ const CMapFactory = (function CMapFactoryClosure() {
901
901
902
902
function parseCMapName ( cMap , lexer ) {
903
903
const obj = lexer . getObj ( ) ;
904
- if ( obj instanceof Name && isString ( obj . name ) ) {
904
+ if ( obj instanceof Name ) {
905
905
cMap . name = obj . name ;
906
906
}
907
907
}
Original file line number Diff line number Diff line change @@ -24,6 +24,13 @@ const Name = (function NameClosure() {
24
24
// eslint-disable-next-line no-shadow
25
25
class Name {
26
26
constructor ( name ) {
27
+ if (
28
+ ( typeof PDFJSDev === "undefined" ||
29
+ PDFJSDev . test ( "!PRODUCTION || TESTING" ) ) &&
30
+ typeof name !== "string"
31
+ ) {
32
+ unreachable ( 'Name: The "name" must be a string.' ) ;
33
+ }
27
34
this . name = name ;
28
35
}
29
36
@@ -47,6 +54,13 @@ const Cmd = (function CmdClosure() {
47
54
// eslint-disable-next-line no-shadow
48
55
class Cmd {
49
56
constructor ( cmd ) {
57
+ if (
58
+ ( typeof PDFJSDev === "undefined" ||
59
+ PDFJSDev . test ( "!PRODUCTION || TESTING" ) ) &&
60
+ typeof cmd !== "string"
61
+ ) {
62
+ unreachable ( 'Cmd: The "cmd" must be a string.' ) ;
63
+ }
50
64
this . cmd = cmd ;
51
65
}
52
66
Original file line number Diff line number Diff line change @@ -55,6 +55,12 @@ describe("primitives", function () {
55
55
expect ( firstEmpty ) . toBe ( secondEmpty ) ;
56
56
expect ( firstEmpty ) . not . toBe ( normalName ) ;
57
57
} ) ;
58
+
59
+ it ( "should not accept to create a non-string name" , function ( ) {
60
+ expect ( function ( ) {
61
+ Name . get ( 123 ) ;
62
+ } ) . toThrow ( new Error ( 'Name: The "name" must be a string.' ) ) ;
63
+ } ) ;
58
64
} ) ;
59
65
60
66
describe ( "Cmd" , function ( ) {
@@ -74,6 +80,12 @@ describe("primitives", function () {
74
80
expect ( firstET ) . toBe ( secondET ) ;
75
81
expect ( firstBT ) . not . toBe ( firstET ) ;
76
82
} ) ;
83
+
84
+ it ( "should not accept to create a non-string cmd" , function ( ) {
85
+ expect ( function ( ) {
86
+ Cmd . get ( 123 ) ;
87
+ } ) . toThrow ( new Error ( 'Cmd: The "cmd" must be a string.' ) ) ;
88
+ } ) ;
77
89
} ) ;
78
90
79
91
describe ( "Dict" , function ( ) {
You can’t perform that action at this time.
0 commit comments