This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new b45d0fb8b fix(web): treat CR-only line endings as property record
separators (#7121)
b45d0fb8b is described below
commit b45d0fb8b038c67da2c9f1b2964c043d29df3cfd
Author: bob <[email protected]>
AuthorDate: Fri Nov 27 12:00:45 2026 +0800
fix(web): treat CR-only line endings as property record separators (#7121)
---
web/src/utils/messageProperties.test.ts | 17 +++++++++++++++++
web/src/utils/messageProperties.ts | 3 ++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/web/src/utils/messageProperties.test.ts
b/web/src/utils/messageProperties.test.ts
index 7be1fac51..09c013d61 100644
--- a/web/src/utils/messageProperties.test.ts
+++ b/web/src/utils/messageProperties.test.ts
@@ -34,6 +34,23 @@ describe('parseMessageProperties', () => {
});
});
+ it('treats CR-only and mixed line endings as record separators', () => {
+ const result = parseMessageProperties(
+ 'traceId=one\rtenant=demo\nregion=cn\rsignature=a=1\r\nenv=prod',
+ );
+
+ expect(result).toEqual({
+ properties: {
+ traceId: 'one',
+ tenant: 'demo',
+ region: 'cn',
+ signature: 'a=1',
+ env: 'prod',
+ },
+ errors: [],
+ });
+ });
+
it('supports Windows line endings and reports duplicate keys', () => {
const result =
parseMessageProperties('traceId=first\r\ntenant=demo\r\ntraceId=second');
diff --git a/web/src/utils/messageProperties.ts
b/web/src/utils/messageProperties.ts
index cec11a6f9..087b96b66 100644
--- a/web/src/utils/messageProperties.ts
+++ b/web/src/utils/messageProperties.ts
@@ -21,11 +21,12 @@ interface ParsedProperties {
}
// 解析批量粘贴的用户属性串:每行一个 key=value,等号只取第一个。
+// CR、LF、CRLF 及混合换行都视为记录分隔符,避免纯 CR 粘贴时后续属性被吞进前一个值。
// 逗号属于合法属性值,不能同时作为记录分隔符,否则会破坏地址、列表等常见值。
export const parseMessageProperties = (text: string): ParsedProperties => {
const entries = new Map<string, string>();
const errors: string[] = [];
- for (const line of text.split(/\r?\n/)) {
+ for (const line of text.split(/\r\n|\r|\n/)) {
const trimmed = line.trim();
if (!trimmed) continue;
const eqIndex = trimmed.indexOf('=');