Copilot commented on code in PR #2872:
URL: https://github.com/apache/tika/pull/2872#discussion_r3363963514


##########
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-html-module/src/main/java/org/apache/tika/parser/html/JSoupParser.java:
##########
@@ -165,6 +166,9 @@ public void parse(TikaInputStream tis, ContentHandler 
handler, Metadata metadata
                 : encResults.get(0).getCharset();
         Charset decodeAs = encResults.isEmpty() ? DEFAULT_CHARSET
                 : encResults.get(0).getDecodeAs();
+        if (!decodeAs.equals(charset)) {
+            metadata.set(TikaCoreProperties.DECODED_CHARSET, decodeAs.name());
+        }

Review Comment:
   `DECODED_CHARSET` is only set when `decodeAs` differs from the detected 
`charset`, but it is never cleared when they are equal. If the same `Metadata` 
instance is reused across parses, a previously-set `decodedCharset` value can 
leak into a later parse that did *not* use a superset override, misleading 
callers about which charset was actually used. Clear the field before 
conditionally setting it for this parse.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to