@@ -376,6 +376,7 @@ describe("XMLParser Entities", function() {
376
376
377
377
expect ( result ) . toEqual ( expected ) ;
378
378
} ) ;
379
+
379
380
it ( "should throw error if an entity name contains special char" , function ( ) {
380
381
const xmlData = `
381
382
<?xml version="1.0" encoding="UTF-8"?>
@@ -392,7 +393,48 @@ describe("XMLParser Entities", function() {
392
393
expect ( ( ) => {
393
394
const parser = new XMLParser ( options ) ;
394
395
parser . parse ( xmlData ) ;
395
- } ) . toThrowError ( "Invalid character $ in entity name" )
396
+ } ) . toThrowError ( "Invalid entity name nj$" )
397
+ } ) ;
398
+
399
+ it ( "should allow localised entity names" , function ( ) {
400
+ const xmlData = `
401
+ <?xml version="1.0" encoding="UTF-8"?>
402
+
403
+ <!DOCTYPE note [
404
+ <!ENTITY ሀሎ "Amharic hello!">
405
+ <!ENTITY Здраво "Macedonian hello.">
406
+ ]>
407
+
408
+ <note>
409
+ <heading>Reminder</heading>
410
+ <body attr="&ሀሎ;">Don't forget me this weekend! &Здраво;</body>
411
+ </note> ` ;
412
+
413
+ const expected = {
414
+ "?xml" : {
415
+ "version" : "1.0" ,
416
+ "encoding" : "UTF-8"
417
+ } ,
418
+ "note" : {
419
+ "heading" : "Reminder" ,
420
+ "body" : {
421
+ "#text" : "Don't forget me this weekend! Macedonian hello." ,
422
+ "attr" : "Amharic hello!"
423
+ }
424
+ }
425
+ } ;
426
+
427
+ const options = {
428
+ attributeNamePrefix : "" ,
429
+ ignoreAttributes : false ,
430
+ processEntities : true ,
431
+ htmlEntities : true
432
+ } ;
433
+ const parser = new XMLParser ( options ) ;
434
+ let result = parser . parse ( xmlData ) ;
435
+ // console.log(JSON.stringify(result,null,4));
436
+
437
+ expect ( result ) . toEqual ( expected ) ;
396
438
} ) ;
397
439
} ) ;
398
440
0 commit comments