From 1fe3365e10c464c4c60c82f424cf74fe35b883e0 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Wed, 26 Feb 2025 21:19:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dwebhook=20headers=20va?= =?UTF-8?q?lue=E4=B8=AD=E5=B8=A6=E7=AD=89=E5=8F=B7=E6=98=AF=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E9=94=99=E8=AF=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/certd/certd/issues/316 --- .../src/plugins/plugin-notification/webhook/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/ui/certd-server/src/plugins/plugin-notification/webhook/index.ts b/packages/ui/certd-server/src/plugins/plugin-notification/webhook/index.ts index d9f061e1..ffda53e7 100644 --- a/packages/ui/certd-server/src/plugins/plugin-notification/webhook/index.ts +++ b/packages/ui/certd-server/src/plugins/plugin-notification/webhook/index.ts @@ -1,5 +1,6 @@ import { BaseNotification, IsNotification, NotificationBody, NotificationInput } from '@certd/pipeline'; import qs from 'qs'; + @IsNotification({ name: 'webhook', title: '自定义webhook', @@ -135,12 +136,13 @@ export class WebhookNotification extends BaseNotification { this.headers.split('\n').forEach(item => { item = item.trim(); if (item) { - const arr = item.split('='); - if (arr.length !== 2) { - this.logger.warn('header格式错误,请使用=号', item); + const eqIndex = item.indexOf('='); + if (eqIndex <= 0) { + this.logger.warn('header格式错误,请使用=号分割', item); return; } - headers[arr[0]] = arr[1]; + const key = item.substring(0, eqIndex); + headers[key] = item.substring(eqIndex + 1); } }); }