You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fesod.apache.org by "BigDataDZ (via GitHub)" <gi...@apache.org> on 2026/09/09 03:47:13 UTC
Re: [I] 列表填充报错 [fesod]
BigDataDZ commented on issue #191:
URL: https://github.com/apache/fesod/issues/191#issuecomment-5595475263
Hi, I dig into this one. The reporter's hint ("super long string in a cell") was the key: any
template cell containing a stray `}` **before** a `{placeholder}` crashes the fill, the string
length is irrelevant.
**Root cause** — in `ExcelWriteFillExecutor#prepareData`, the matching closing suffix for a
placeholder is searched with:
```java
suffixIndex = value.indexOf(FILL_SUFFIX, startIndex + 1);
```
`startIndex` only tracks how far escaped placeholders have been consumed, so the `}` search can
start **before** the current `{`. A stray `}` in the text (e.g. a JSON snippet or any prose with a
brace) is then treated as the placeholder's suffix even though it precedes the `{`, and the
subsequent `value.substring(prefixIndex + 1, suffixIndex)` inverts its bounds — exactly the
`Range [1211, 1027)` from the report.
**Repro** (no proprietary file needed): a template whose first cell contains `a}b{name}`, filled
with `{name: "filled"}`:
```java
// template cell B1... A1 = "a}b{name}"
FesodSheet.write(outFile).withTemplate(template).sheet().doFill(Map.of("name", "filled"));
// current main: java.lang.StringIndexOutOfBoundsException
```
**Fix** (one line): search the suffix after the `{` —
`value.indexOf(FILL_SUFFIX, Math.max(startIndex + 1, prefixIndex + 1))`. A stray `}` is then kept
as literal text (`a}b{name}` fills to `a}bfilled`), escape handling (`\{`, `\}`) and multi
placeholder cells behave exactly as before. Comes with a round-trip regression test
(`FillWithStraySuffixTest`): red on current main, green with the fix.
Will open a PR right away.
--
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: commits-unsubscribe@fesod.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For additional commands, e-mail: commits-help@fesod.apache.org