lllLucario opened a new issue, #1499:
URL: https://github.com/apache/poi/issues/1499
### Affected version
Reproduced with Apache POI HWPF 5.5.1 (poi-scratchpad classes bundled by
Tika 3.3.3), Temurin Java 21. The example compiles for Java 17. Other POI
versions have not been tested; this is not a claim that the current release is
affected.
### Reproduction
This example uses only synthetic text and public/internal POI model APIs. No
user documents, filenames, or proprietary content are attached. It models one
original PAPX interval [0,3) covering `A\r\r`, with explicit in-table=true,
table depth=2 and inner-cell-end=true. Please also assess whether this input
shape needs special validity handling.
```java
// Standalone, original synthetic reproduction. No Briefly classes or user
documents.
import java.util.HexFormat;
import org.apache.poi.hwpf.model.*;
import org.apache.poi.hwpf.sprm.*;
import org.apache.poi.hwpf.usermodel.ParagraphProperties;
public class PoiPapxReproducer {
public static void main(String[] args) {
StringBuilder text=new StringBuilder("A\r\r");
PAPBinTable table=new PAPBinTable();
table.getParagraphs().add(new PAPX(0,3,new
SprmBuffer(HexFormat.of().parseHex("00001624014966020000004b2401"),2)));
ComplexFileTable cft=new ComplexFileTable();
cft.getTextPieceTable().add(new SinglentonTextPiece(text));
table.rebuild(text,cft);
for(PAPX p:table.getParagraphs()) {
ParagraphProperties
props=ParagraphSprmUncompressor.uncompressPAP(new
ParagraphProperties(),p.getGrpprl(),2);
System.out.printf("[%d,%d) inTable=%s depth=%d innerCell=%s
bytes=%s%n",p.getStart(),p.getEnd(),props.getFInTable(),props.getItap(),props.getFInnerTableCell(),HexFormat.of().formatHex(p.getGrpprl()));
}
}
}
```
### Actual output
```
Paragraph [0; 2) has no PAPX. Creating new one.
[0,2) inTable=false depth=0 innerCell=false bytes=000000000000
[2,3) inTable=true depth=2 innerCell=true bytes=00001624014966020000004b2401
```
### Expected behavior / question
Do not silently replace the beginning of an explicitly formatted original
PAPX interval with default non-table properties solely because its text
contains an earlier CR. Either retain the authoritative original paragraph
boundary/property coverage, or explicitly reject/report an unsupported or
invalid source interval. The nested-cell-end flag should apply at the original
cell end, not be blindly copied to every internal CR.
### Why this happens
`PAPBinTable.rebuild` scans CR/0x07/0x0C, then stops collecting the next
PAPX when `papx.getEnd()-1 > charIndex`. At the earlier CR, no PAPX is
collected, so it synthesizes default properties. The original properties are
used only for the final fragment. This can introduce apparent non-table
paragraphs and split otherwise contiguous nested-table ranges.
MS-DOC 2.4.2 locates paragraph boundaries through PCD/PlcBtePapx/PapxFkp;
2.4.6.1 derives direct paragraph properties from that location:
-
https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-doc/30461a5b-e3ad-44cd-a3fe-038f86639b13
-
https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-doc/61b635c3-2c44-4155-bf17-fec281b30c71
No general-purpose patch is proposed here. In particular, skipping arbitrary
non-table paragraphs during table scanning would be unsafe. The intent is to
submit the reproducible property-loss evidence independently of any broader
document-quality investigation.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]