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 6 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
5 changes: 2 additions & 3 deletions src/components/ReportActionItem/IOUQuote.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import {View, Pressable} from 'react-native';
import PropTypes from 'prop-types';
import _ from 'underscore';
import Str from 'expensify-common/lib/str';
import Text from '../Text';
import Icon from '../Icon';
import * as Expensicons from '../Icon/Expensicons';
Expand Down Expand Up @@ -76,14 +75,14 @@ const IOUQuote = props => (
<Text style={[styles.flex1, styles.mr2]}>
<Text style={props.shouldAllowViewDetails && styles.chatItemMessageLink}>
{/* Get first word of IOU message */}
{Str.htmlDecode(fragment.text.split(' ')[0])}
{fragment.text.split(' ')[0]}
</Text>
<Text style={[styles.chatItemMessage, props.shouldAllowViewDetails
? styles.cursorPointer
: styles.cursorDefault]}
>
{/* Get remainder of IOU message */}
{Str.htmlDecode(fragment.text.substring(fragment.text.indexOf(' ')))}
{fragment.text.substring(fragment.text.indexOf(' '))}
</Text>
</Text>
<Icon src={Expensicons.ArrowRight} fill={props.shouldAllowViewDetails ? StyleUtils.getIconFillColor(getButtonState(props.isHovered)) : themeColors.transparent} />
Expand Down
3 changes: 2 additions & 1 deletion src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,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 @@ -1688,6 +1688,7 @@ export {
hashLogin,
getDefaultWorkspaceAvatar,
getCommentLength,
getParsedComment,
openReportFromDeepLink,
getFullSizeAvatar,
getIOUOptions,
Expand Down
6 changes: 4 additions & 2 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 commentText = ReportUtils.getParsedComment(comment);
API.write('RequestMoney', {
debtorEmail,
amount,
currency,
comment,
comment: commentText,
iouReportID: iouReport.reportID,
chatReportID: chatReport.reportID,
transactionID: optimisticReportAction.originalMessage.IOUTransactionID,
Expand Down Expand Up @@ -659,11 +660,12 @@ function buildPayPalPaymentUrl(amount, submitterPayPalMeAddress, currency) {
function getSendMoneyParams(report, amount, currency, comment, paymentMethodType, managerEmail, recipient) {
const recipientEmail = OptionsListUtils.addSMSDomainIfPhoneNumber(recipient.login);

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

Expand Down