fix: 修复webhook headers value中带等号是解析错误的bug

https://github.com/certd/certd/issues/316
v2-dev
xiaojunnuo 2025-02-26 21:19:58 +08:00
parent f0584c88e8
commit 1fe3365e10
1 changed files with 6 additions and 4 deletions

View File

@ -1,5 +1,6 @@
import { BaseNotification, IsNotification, NotificationBody, NotificationInput } from '@certd/pipeline'; import { BaseNotification, IsNotification, NotificationBody, NotificationInput } from '@certd/pipeline';
import qs from 'qs'; import qs from 'qs';
@IsNotification({ @IsNotification({
name: 'webhook', name: 'webhook',
title: '自定义webhook', title: '自定义webhook',
@ -135,12 +136,13 @@ export class WebhookNotification extends BaseNotification {
this.headers.split('\n').forEach(item => { this.headers.split('\n').forEach(item => {
item = item.trim(); item = item.trim();
if (item) { if (item) {
const arr = item.split('='); const eqIndex = item.indexOf('=');
if (arr.length !== 2) { if (eqIndex <= 0) {
this.logger.warn('header格式错误,请使用=号', item); this.logger.warn('header格式错误,请使用=号分割', item);
return; return;
} }
headers[arr[0]] = arr[1]; const key = item.substring(0, eqIndex);
headers[key] = item.substring(eqIndex + 1);
} }
}); });
} }