Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse comment before sending it to the back-end to preserve HTML entities #16055

Merged
merged 10 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ function getIOUReportActionMessage(type, total, participants, comment, currency,
}

return [{
html: iouMessage,
html: getParsedComment(iouMessage),
text: iouMessage,
isEdited: false,
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
Expand Down Expand Up @@ -1709,6 +1709,7 @@ export {
hashLogin,
getDefaultWorkspaceAvatar,
getCommentLength,
getParsedComment,
getFullSizeAvatar,
getSmallSizeAvatar,
getIOUOptions,
Expand Down
13 changes: 8 additions & 5 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,12 @@ function requestMoney(report, amount, currency, recipientEmail, participant, com
reportActionsFailureData,
];

const parsedComment = ReportUtils.getParsedComment(comment);
API.write('RequestMoney', {
debtorEmail,
amount,
currency,
comment,
comment: parsedComment,
iouReportID: iouReport.reportID,
chatReportID: chatReport.reportID,
transactionID: optimisticReportAction.originalMessage.IOUTransactionID,
Expand Down Expand Up @@ -490,13 +491,14 @@ function createSplitsAndOnyxData(participants, currentUserLogin, amount, comment
*/
function splitBill(participants, currentUserLogin, amount, comment, currency, locale, existingGroupChatReportID = '') {
const {groupData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, amount, comment, currency, locale, existingGroupChatReportID);
const parsedComment = ReportUtils.getParsedComment(comment);

API.write('SplitBill', {
reportID: groupData.chatReportID,
amount: Math.round(amount * 100),
splits: JSON.stringify(splits),
currency,
comment,
comment: parsedComment,
transactionID: groupData.transactionID,
reportActionID: groupData.reportActionID,
createdReportActionID: groupData.createdReportActionID,
Expand All @@ -515,13 +517,14 @@ function splitBill(participants, currentUserLogin, amount, comment, currency, lo
*/
function splitBillAndOpenReport(participants, currentUserLogin, amount, comment, currency, locale) {
const {groupData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, amount, comment, currency, locale);
const parsedComment = ReportUtils.getParsedComment(comment);

API.write('SplitBillAndOpenReport', {
reportID: groupData.chatReportID,
amount: Math.round(amount * 100),
splits: JSON.stringify(splits),
currency,
comment,
comment: parsedComment,
transactionID: groupData.transactionID,
reportActionID: groupData.reportActionID,
createdReportActionID: groupData.createdReportActionID,
Expand Down Expand Up @@ -655,12 +658,12 @@ function buildPayPalPaymentUrl(amount, submitterPayPalMeAddress, currency) {
*/
function getSendMoneyParams(report, amount, currency, comment, paymentMethodType, managerEmail, recipient) {
const recipientEmail = OptionsListUtils.addSMSDomainIfPhoneNumber(recipient.login);

const parsedComment = ReportUtils.getParsedComment(comment);
const newIOUReportDetails = JSON.stringify({
amount,
currency,
requestorEmail: recipientEmail,
comment,
comment: parsedComment,
idempotencyKey: Str.guid(),
});

Expand Down