@@ -781,14 +781,43 @@ void testBadAttr2() throws XmpParsingException
781781 XmpParsingException ex = assertThrows (
782782 XmpParsingException .class ,
783783 () -> xmpParser1 .parse (s .getBytes (StandardCharsets .UTF_8 )));
784- assertEquals ("The type 'Flash' in 'exif:Flash=1' is a structured type, but attributes are simple types" , ex .getMessage ());
784+ assertEquals ("The type 'Flash' in 'exif:Flash=1' is a structured or array type, but attributes are simple types" , ex .getMessage ());
785785 final DomXmpParser xmpParser2 = new DomXmpParser ();
786786 xmpParser2 .setStrictParsing (false );
787787 XMPMetadata xmp = xmpParser2 .parse (s .getBytes (StandardCharsets .UTF_8 ));
788788 ExifSchema exifSchema = (ExifSchema ) xmp .getSchema (ExifSchema .class );
789789 assertEquals ("[Flash=TextType:1]" , exifSchema .getProperty (ExifSchema .FLASH ).toString ());
790790 }
791791
792+ @ Test
793+ void testBadAttr3 () throws XmpParsingException , TransformerException
794+ {
795+ // test text in attribute which should have been an array property
796+ String s = "<?xml version=\" 1.0\" encoding=\" UTF-8\" standalone=\" no\" ?>\n " +
797+ "<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d' bytes='1064'?><rdf:RDF xmlns:rdf=\" http://www.w3.org/1999/02/22-rdf-syntax-ns#\" >\n " +
798+ " <rdf:Description xmlns=\" http://purl.org/dc/elements/1.1/\" xmlns:dc=\" http://purl.org/dc/elements/1.1/\" about=\" \" dc:creator=\" Creator\" />\n " +
799+ "</rdf:RDF><?xpacket end='r'?>" ;
800+ final DomXmpParser xmpParser1 = new DomXmpParser ();
801+ XmpParsingException ex = assertThrows (XmpParsingException .class ,
802+ () -> xmpParser1 .parse (s .getBytes (StandardCharsets .UTF_8 )));
803+ assertEquals ("The type 'Text' in 'dc:creator=Creator' is a structured or array type, but attributes are simple types" , ex .getMessage ());
804+ DomXmpParser xmpParser2 = new DomXmpParser ();
805+ xmpParser2 .setStrictParsing (false );
806+ XMPMetadata xmp2 = xmpParser2 .parse (s .getBytes (StandardCharsets .UTF_8 ));
807+ XmpSerializer serializer = new XmpSerializer ();
808+ ByteArrayOutputStream baos = new ByteArrayOutputStream ();
809+ // make sure that nothing is lost in serialization
810+ serializer .serialize (xmp2 , baos , true );
811+ final DomXmpParser xmpParser3 = new DomXmpParser ();
812+ ex = assertThrows (XmpParsingException .class , () -> xmpParser3 .parse (baos .toByteArray ()));
813+ assertEquals ("Invalid array definition, expecting Seq and found Text [prefix=dc; name=creator]" , ex .getMessage ());
814+ DomXmpParser xmpParser4 = new DomXmpParser ();
815+ xmpParser4 .setStrictParsing (false );
816+ XMPMetadata xmp4 = xmpParser4 .parse (baos .toByteArray ());
817+ DublinCoreSchema dublinCoreSchema = xmp4 .getDublinCoreSchema ();
818+ assertEquals ("[creator=TextType:Creator]" , dublinCoreSchema .getProperty (DublinCoreSchema .CREATOR ).toString ());
819+ }
820+
792821 @ Test
793822 void testBadSchema () throws XmpParsingException
794823 {
0 commit comments