Skip to content

Commit 49f6805

Browse files
danfercf1Daniel Candia Flores
and
Daniel Candia Flores
authored
Issue 543 error displaying username with underscore (lnp2pBot#586)
* Escape underscore on dispute message for admin solver and add unit tests * Update TG id for translation * Resolve linter errors * Updated package-json with proxiquiry module * Fix error UnknownArrayOrTuple * Test QL security fix * 2nd attempt CodeQL issue * 3rd attempt CodeQL issue * 4th attempt CodeQL issue * Update the MD sanitize with implemented method and fix the issue in the translation file * Update other languages translations --------- Co-authored-by: Daniel Candia Flores <[email protected]>
1 parent 5c13f3e commit 49f6805

File tree

14 files changed

+2570
-1793
lines changed

14 files changed

+2570
-1793
lines changed

bot/modules/dispute/messages.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { getDisputeChannel, getDetailedOrder } = require('../../../util');
1+
const { getDisputeChannel, getDetailedOrder, sanitizeMD } = require('../../../util');
22
const { logger } = require('../../../logger');
33

44
exports.beginDispute = async (ctx, initiator, order, buyer, seller) => {
@@ -87,11 +87,18 @@ exports.disputeData = async (
8787
}
8888

8989
const detailedOrder = getDetailedOrder(ctx.i18n, order, buyer, seller);
90+
91+
// Fix Issue 543: Escape underscores in usernames
92+
const escapedInitiatorUsername = sanitizeMD(initiatorUser.username);
93+
const escapedCounterPartyUsername = sanitizeMD(counterPartyUser.username);
94+
9095
await ctx.telegram.sendMessage(
9196
solver.tg_id,
9297
ctx.i18n.t('dispute_started_channel', {
93-
initiatorUser,
94-
counterPartyUser,
98+
initiatorUser: { ...initiatorUser, username: escapedInitiatorUsername },
99+
initiatorTgId: initiatorUser.tg_id,
100+
counterPartyUser: { ...counterPartyUser, username: escapedCounterPartyUsername },
101+
counterPartyUserTgId: counterPartyUser.tg_id,
95102
buyer,
96103
seller,
97104
buyerDisputes,
@@ -108,14 +115,14 @@ exports.disputeData = async (
108115
await ctx.telegram.sendMessage(
109116
buyer.tg_id,
110117
ctx.i18n.t('dispute_solver', {
111-
solver: solver.username,
118+
solver: sanitizeMD(solver.username),
112119
token: order.buyer_dispute_token,
113120
})
114121
);
115122
await ctx.telegram.sendMessage(
116123
seller.tg_id,
117124
ctx.i18n.t('dispute_solver', {
118-
solver: solver.username,
125+
solver: sanitizeMD(solver.username),
119126
token: order.seller_dispute_token,
120127
})
121128
);

locales/de.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ order_detail: |
202202
seller: Käufer
203203
buyer: Verkäufer
204204
dispute_started_channel: |
205-
Benutzer ${type} @${initiatorUser.username}
206-
hat einen Streitfall mit @${counterPartyUser.username} für den folgenden Auftrag eröffnet
205+
Benutzer ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
206+
hat einen Streitfall mit @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} für den folgenden Auftrag eröffnet
207207
208208
${detailedOrder}
209209

locales/en.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ order_detail: |
204204
seller: seller
205205
buyer: buyer
206206
dispute_started_channel: |
207-
User ${type} @${initiatorUser.username}
208-
has started a dispute with @${counterPartyUser.username} for the order
207+
User ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
208+
has started a dispute with @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} for the order
209209
210210
${detailedOrder}
211211

locales/es.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,16 @@ order_detail: |
202202
seller: vendedor
203203
buyer: comprador
204204
dispute_started_channel: |
205-
El ${type} @${initiatorUser.username}
206-
ha iniciado una disputa con @${counterPartyUser.username} en la orden:
205+
El ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
206+
ha iniciado una disputa con @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} en la orden:
207207
208208
${detailedOrder}
209209
210210
Seller Token: ${sellerToken}
211211
Buyer Token: ${buyerToken}
212212
213-
@${buyer.username} ya tiene ${buyerDisputes} disputas
214-
@${seller.username} ya tiene ${sellerDisputes} disputas
213+
@${initiatorUser.username} ya tiene ${buyerDisputes} disputas
214+
@${counterPartyUser.username} ya tiene ${sellerDisputes} disputas
215215
you_started: '🥴 Has iniciado una disputa en tu orden con Id: ${orderId}.'
216216
counterpart_started: '🥴 Tu contraparte ha iniciado una disputa en tu orden con Id: ${orderId}.'
217217
dispute_started: '${who} Un solver te atenderá pronto, cuando él/la solver sea asignado a tu disputa el bot te dirá su username, solo él/ella podrá atenderte. Puedes escribirle directamente, pero si él/ella te contacta primero, debes pedirle que te diga cuál es el token de tu disputa, tu token es: ${token}.'

locales/fa.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ order_detail: |
204204
seller: seller
205205
buyer: buyer
206206
dispute_started_channel: |
207-
کاربر ${type} @${initiatorUser.username}
208-
بابت سفارش زیر یک مشاجره را با کاربر @${counterPartyUser.username}آغاز کرده
207+
کاربر ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
208+
بابت سفارش زیر یک مشاجره را با کاربر @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} آغاز کرده
209209
210210
${detailedOrder}
211211

locales/fr.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ order_detail: |
204204
seller: vendeur
205205
buyer: acheteur
206206
dispute_started_channel: |
207-
L'utilisateur ${type} @${initiatorUser.username}
208-
à déclenché un litige avec @${counterPartyUser.username} concernant l'offre
207+
L'utilisateur ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
208+
à déclenché un litige avec @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} concernant l'offre
209209
210210
${detailedOrder}
211211

locales/it.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ order_detail: |
202202
seller: venditore
203203
buyer: acquirente
204204
dispute_started_channel: |
205-
User ${type} @${initiatorUser.username}
206-
ha iniziato una disputa con @${counterPartyUser.username} per l'ordine
205+
User ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
206+
ha iniziato una disputa con @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} per l'ordine
207207
208208
${detailedOrder}
209209

locales/ko.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ order_detail: |
203203
seller: 판매자
204204
buyer: 구매자
205205
dispute_started_channel: |
206-
사용자 ${type} @${initiatorUser.username}
207-
님께서 @${counterPartyUser.username}와의 분쟁 조정을 시작하였습니다. 주문 상세 내역은 다음과 같습니다.
206+
사용자 ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
207+
님께서 @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} 와의 분쟁 조정을 시작하였습니다. 주문 상세 내역은 다음과 같습니다.
208208
209209
${detailedOrder}
210210

locales/pt.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ order_detail: |
201201
seller: vendedora
202202
buyer: compradora
203203
dispute_started_channel: |
204-
Usuário ${type} @${initiatorUser.username}
205-
iniciou uma disputa com @${counterPartyUser.username} para o pedido
204+
Usuário ${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
205+
iniciou uma disputa com @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} para o pedido
206206
207207
${detailedOrder}
208208

locales/ru.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ order_detail: |
201201
seller: продавец
202202
buyer: покупатель
203203
dispute_started_channel: |
204-
${type} @${initiatorUser.username}
205-
инициировал разбирательство с @${counterPartyUser.username} относительно заявки:
204+
${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
205+
инициировал разбирательство с @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} относительно заявки:
206206
207207
${detailedOrder}
208208

locales/uk.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ order_detail: |
201201
seller: продавець
202202
buyer: покупець
203203
dispute_started_channel: |
204-
${type} @${initiatorUser.username}
205-
ініціював диспут з @${counterPartyUser.username} щодо заявки:
204+
${type} @${initiatorUser.username} TG ID: ${initiatorTgId}
205+
ініціював диспут з @${counterPartyUser.username} TG ID: ${counterPartyUserTgId} щодо заявки:
206206
207207
${detailedOrder}
208208

0 commit comments

Comments
 (0)