diff --git a/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/Breaker.java b/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/Breaker.java index 6efa09e55..749b21ee8 100644 --- a/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/Breaker.java +++ b/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/Breaker.java @@ -159,6 +159,8 @@ public static LineBreakResult breakText(LayoutContext c, break LOOP; } else { // We may be at the end of the line, so pick up at next line. + // FIXME: This is very dangerous and has led to infinite + // loops. Needs review. context.setEnd(savedEnd); break LOOP; } diff --git a/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/InlineBoxing.java b/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/InlineBoxing.java index fddd8893b..b3e8ff1af 100644 --- a/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/InlineBoxing.java +++ b/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/InlineBoxing.java @@ -441,7 +441,9 @@ private static StartInlineTextResult startInlineText( } if (!lbContext.isUnbreakable() || - (lbContext.isUnbreakable() && !current.line.isContainsContent())) { + (lbContext.isUnbreakable() && + !current.line.isContainsContent() && + lbContext.getEnd() > lbContext.getStart())) { // We can use the inline text by adding it to the current inline layout box. // We also mark the text as consumed by the line break context and reduce the width // we have remaining on this line.