You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2025/01/28 16:41:53 UTC

(tika) branch main updated: TIKA-4361 -- follow on fix (#2108)

This is an automated email from the ASF dual-hosted git repository.

tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/main by this push:
     new 05db89db3 TIKA-4361 -- follow on fix (#2108)
05db89db3 is described below

commit 05db89db3d24c13ee8794999c18af3a0b9a094e5
Author: Tim Allison <ta...@apache.org>
AuthorDate: Tue Jan 28 11:41:47 2025 -0500

    TIKA-4361 -- follow on fix (#2108)
---
 .../tika/parser/microsoft/rtf/TextExtractor.java   | 69 ++++++++++++----------
 1 file changed, 39 insertions(+), 30 deletions(-)

diff --git a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/rtf/TextExtractor.java b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/rtf/TextExtractor.java
index 5d57ca362..1fe173259 100644
--- a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/rtf/TextExtractor.java
+++ b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/rtf/TextExtractor.java
@@ -941,27 +941,32 @@ final class TextExtractor {
         } else {
             // In document
             if (equals("b")) {
-                //TIKA-4361 -- need to make sure we're not in an href?
                 // b0
                 assert param == 0;
-                if (groupState.bold) {
-                    pushText();
-                    if (groupState.italic) {
-                        end("i");
-                    }
-                    end("b");
-                    if (groupState.italic) {
-                        start("i");
+                //only modify styles if we're not in a hyperlink
+                if (fieldState == 0) {
+                    if (groupState.bold) {
+                        pushText();
+                        if (groupState.italic) {
+                            end("i");
+                        }
+                        end("b");
+                        if (groupState.italic) {
+                            start("i");
+                        }
+                        groupState.bold = false;
                     }
-                    groupState.bold = false;
                 }
             } else if (equals("i")) {
                 // i0
                 assert param == 0;
-                if (groupState.italic) {
-                    pushText();
-                    end("i");
-                    groupState.italic = false;
+                //only modify styles if we're not in a hyperlink
+                if (fieldState == 0) {
+                    if (groupState.italic) {
+                        pushText();
+                        end("i");
+                        groupState.italic = false;
+                    }
                 }
             } else if (equals("f")) {
                 // Change current font
@@ -1174,23 +1179,27 @@ final class TextExtractor {
                 inHeader = false;
             }
         } else {
-            if (equals("b")) {
-                if (!groupState.bold) {
-                    pushText();
-                    lazyStartParagraph();
-                    if (groupState.italic) {
-                        // Make sure nesting is always <b><i>
-                        end("i");
+            //only modify styles if we're not in a hyperlink
+            if (fieldState == 0) {
+                if (equals("b")) {
+                    if (!groupState.bold) {
+                        pushText();
+                        lazyStartParagraph();
+                        if (groupState.italic) {
+                            // Make sure nesting is always <b><i>
+                            end("i");
+                        }
+                        groupState.bold = true;
+                        startStyles(groupState);
+                    }
+                } else if (equals("i")) {
+                    //START I
+                    if (!groupState.italic) {
+                        pushText();
+                        lazyStartParagraph();
+                        groupState.italic = true;
+                        start("i");
                     }
-                    groupState.bold = true;
-                    startStyles(groupState);
-                }
-            } else if (equals("i")) {
-                if (!groupState.italic) {
-                    pushText();
-                    lazyStartParagraph();
-                    groupState.italic = true;
-                    start("i");
                 }
             }
         }