Skip to content

Commit

Permalink
fix: remove Str.htmlDecode
Browse files Browse the repository at this point in the history
  • Loading branch information
tienifr committed Mar 21, 2023
1 parent 0c40bc1 commit 7067ae8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
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.html.substring(fragment.html.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: 1 addition & 2 deletions src/components/ReportTransaction.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {View} from 'react-native';
import Str from 'expensify-common/lib/str';
import styles from '../styles/styles';
import CONST from '../CONST';
import * as IOU from '../libs/actions/IOU';
Expand Down Expand Up @@ -77,7 +76,7 @@ class ReportTransaction extends Component {
wrapperStyles={[styles.reportTransactionWrapper]}
>
<Text style={[styles.chatItemMessage]}>
{Str.htmlDecode(this.props.action.message[0].html)}
{this.props.action.message[0].text}
</Text>
</ReportActionItemSingle>
{this.props.canBeRejected && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Web and desktop implementation only. Do not import for direct use. Use LocalNotification.
import _ from 'underscore';
import Str from 'expensify-common/lib/str';
import focusApp from './focusApp';
import * as AppUpdate from '../../actions/AppUpdate';
import EXPENSIFY_ICON_URL from '../../../../assets/images/expensify-logo-round-clearspace.png';
Expand Down Expand Up @@ -110,7 +109,7 @@ export default {
const plainTextPerson = _.map(person, f => f.text).join();

// Specifically target the comment part of the message
const plainTextMessage = Str.htmlDecode((_.find(message, f => f.type === 'COMMENT') || {}).text);
const plainTextMessage = (_.find(message, f => f.type === 'COMMENT') || {}).text;

push({
title: plainTextPerson,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ function createOption(logins, personalDetails, report, reportActions = {}, {
if (ReportUtils.isReportMessageAttachment({text: report.lastMessageText, html: report.lastMessageHtml})) {
lastMessageTextFromReport = `[${Localize.translateLocal('common.attachment')}]`;
} else {
lastMessageTextFromReport = Str.htmlDecode(report ? report.lastMessageText : '');
lastMessageTextFromReport = report ? report.lastMessageText : '';
}

const lastActorDetails = personalDetailMap[report.lastActorEmail] || null;
Expand Down
13 changes: 6 additions & 7 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -955,11 +955,10 @@ function buildOptimisticIOUReport(ownerEmail, userEmail, total, chatReportID, cu
*/
function getIOUReportActionMessage(type, total, participants, comment, currency, paymentType = '', isSettlingUp = false) {
const amount = NumberFormatUtils.format(preferredLocale, total / 100, {style: 'currency', currency});
const displayNames = _.map(participants, participant => Str.htmlEncode(getDisplayNameForParticipant(participant.login, true)));
const displayNames = _.map(participants, participant => getDisplayNameForParticipant(participant.login, true));
const who = displayNames.length < 3
? displayNames.join(' and ')
: `${displayNames.slice(0, -1).join(', ')}, and ${_.last(displayNames)}`;
const encodedComment = Str.htmlEncode(comment);
let paymentMethodMessage;
switch (paymentType) {
case CONST.IOU.PAYMENT_TYPE.EXPENSIFY:
Expand All @@ -978,21 +977,21 @@ function getIOUReportActionMessage(type, total, participants, comment, currency,
let iouMessage;
switch (type) {
case CONST.IOU.REPORT_ACTION_TYPE.CREATE:
iouMessage = `Requested ${amount} from ${who}${comment && ` for ${encodedComment}`}`;
iouMessage = `Requested ${amount} from ${who}${comment && ` for ${comment}`}`;
break;
case CONST.IOU.REPORT_ACTION_TYPE.SPLIT:
iouMessage = `Split ${amount} with ${who}${comment && ` for ${encodedComment}`}`;
iouMessage = `Split ${amount} with ${who}${comment && ` for ${comment}`}`;
break;
case CONST.IOU.REPORT_ACTION_TYPE.CANCEL:
iouMessage = `Cancelled the ${amount} request${comment && ` for ${encodedComment}`}`;
iouMessage = `Cancelled the ${amount} request${comment && ` for ${comment}`}`;
break;
case CONST.IOU.REPORT_ACTION_TYPE.DECLINE:
iouMessage = `Declined the ${amount} request${comment && ` for ${encodedComment}`}`;
iouMessage = `Declined the ${amount} request${comment && ` for ${comment}`}`;
break;
case CONST.IOU.REPORT_ACTION_TYPE.PAY:
iouMessage = isSettlingUp
? `Settled up${paymentMethodMessage}`
: `Sent ${amount}${comment && ` for ${encodedComment}`}${paymentMethodMessage}`;
: `Sent ${amount}${comment && ` for ${comment}`}${paymentMethodMessage}`;
break;
default:
break;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ function getOptionData(reportID) {
if (ReportUtils.isReportMessageAttachment({text: report.lastMessageText, html: report.lastMessageHtml})) {
lastMessageTextFromReport = `[${Localize.translateLocal('common.attachment')}]`;
} else {
lastMessageTextFromReport = Str.htmlDecode(report ? report.lastMessageText : '');
lastMessageTextFromReport = report ? report.lastMessageText : '';
}

const lastActorDetails = personalDetails[report.lastActorEmail] || null;
Expand Down

0 comments on commit 7067ae8

Please sign in to comment.