kinow commented on a change in pull request #4: IPTCParser now takes the raw 
bytes of an IPTCRecord element into account
URL: https://github.com/apache/commons-imaging/pull/4#discussion_r344474762
 
 

 ##########
 File path: 
src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java
 ##########
 @@ -438,10 +438,20 @@ public int compare(final IptcRecord e1, final IptcRecord 
e2) {
                 }
                 bos.write(element.iptcType.getType());
 
-                final byte[] recordData = element.value.getBytes("ISO-8859-1");
-                if (!new String(recordData, 
"ISO-8859-1").equals(element.value)) {
-                    throw new ImageWriteException(
-                            "Invalid record value, not ISO-8859-1");
+                /**
+                 * favor raw bytes over value. This allows callers to use their
+                 * own encoding of fields.
+                 */
+                final byte[] recordData;
+                if( element.getRawBytes() != null && 
element.getRawBytes().length > 0 ) {
 
 Review comment:
   Ah, I had a better look using the [git 
history](https://github.com/apache/commons-imaging/commit/df41d46a01618a04c8f411c775f7df7f17e2c5e5#diff-ac232ea300229a1690ebdfdfec87bc99),
 and `getRawBytes` returned the bytes returned from a `getBytes("ISO-8859-1")` 
call.
   
   
![image](https://user-images.githubusercontent.com/304786/68539946-b2336080-03ef-11ea-8735-ae060c40717e.png)
   
   So the only way that `getRawBytes` would return `null`, would be if there 
was an error encoding the String into ISO-8859-1. Which would also happen in 
the other branch of the `if` statement here.
   
   So I believe the change wouldn't help you, as we would be still using 
ISO-8859-1 before you got the bytes. 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to