tju-yxq opened a new issue, #5514: URL: https://github.com/apache/rocketmq-dashboard/issues/5514
## Problem The server-side CSV escaper (`CsvUtil.toCell`) only prefixes the protection apostrophe when a value starts **directly** with a formula character (`= + - @ TAB CR LF`). The web escaper (`escapeCsvCell` in `web/src/utils/download.ts`) additionally escapes **apostrophe-prefixed formulas** — values like `'=cmd|...'` or `'-tag` that start with one or more apostrophes followed by a formula character. This asymmetry is not just cosmetic, because the web importer completes the protocol. `resourceCsvImport.ts` strips exactly one protection apostrophe from any cell whose remainder still starts a formula: ```ts const FORMULA_SAFE_PREFIX_PATTERN = /^'(?='*[=+\-@\t\r\n])/; ``` The round trip works only when the exporter adds a second apostrophe to apostrophe-prefixed values. Concretely, with a topic whose `Remark` (free text) is `'-- prod --'`: 1. **Server export** (topic page export goes through `MetadataService.exportTopics` → `CsvUtil`): the remark starts with `'`, so no protection is added; the CSV cell is `'-- prod --'`. 2. **Web import** of that file: the strip pattern matches (`'` followed by `-`), so the user's apostrophe is silently deleted — the imported remark becomes `-- prod --'`. 3. The value now starts with `-`; every later export shows the mutated data, and the stored remark no longer matches what the user typed. So a server-produced topic/consumer-group export loses user data through the app's own export → import round trip, while a frontend-produced CSV of the same value survives it. The audit log and cloud credential exports have the same gap relative to the web escaper's protection level. ## Expected behavior `CsvUtil.toCell` applies the same escape rule as `escapeCsvCell`: prefix the protection apostrophe for values starting with a formula character **or** with one or more apostrophes followed by a formula character, so that stripping exactly one leading apostrophe (the importer's rule) always restores the original value. ## Notes - All three server exporters (topic/consumer group CSV in `MetadataService`, audit log CSV in `AuditService`, cloud credential CSV in `CloudCredentialService`) route through `CsvUtil.appendRow`, so the fix is one place. - Plain apostrophe values without a following formula character (`it's fine`, `'quoted'`) must stay untouched — the importer does not strip those. -- 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]
