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

Removed redundant Str.htmlDecode #20443

Merged
merged 6 commits into from
Jun 14, 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
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"babel-polyfill": "^6.26.0",
"dom-serializer": "^0.2.2",
"domhandler": "^4.3.0",
"expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#50aacd53fe54ef7131e5cb9c74ee4526b3bcfe16",
"expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#a1e97c5e236ae7bc10623da6db9847bbd91863ab",
"fbjs": "^3.0.2",
"html-entities": "^1.3.1",
"htmlparser2": "^7.2.0",
Expand Down
4 changes: 1 addition & 3 deletions src/components/CopySelectionHelper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import Str from 'expensify-common/lib/str';
import CONST from '../CONST';
import KeyboardShortcut from '../libs/KeyboardShortcut';
import Clipboard from '../libs/Clipboard';
Expand Down Expand Up @@ -36,8 +35,7 @@ class CopySelectionHelper extends React.Component {
Clipboard.setString(parser.htmlToMarkdown(selection));
return;
}

Clipboard.setHtml(selection, Str.htmlDecode(parser.htmlToText(selection)));
Clipboard.setHtml(selection, parser.htmlToText(selection));
}

render() {
Expand Down
6 changes: 3 additions & 3 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,12 +659,12 @@ function canShowReportRecipientLocalTime(personalDetails, report, login) {
}

/**
* Html decode, shorten last message text to fixed length and trim spaces.
* Shorten last message text to fixed length and trim spaces.
* @param {String} lastMessageText
* @returns {String}
*/
function formatReportLastMessageText(lastMessageText) {
return Str.htmlDecode(String(lastMessageText)).trim().replace(CONST.REGEX.AFTER_FIRST_LINE_BREAK, '').substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim();
return String(lastMessageText).trim().replace(CONST.REGEX.AFTER_FIRST_LINE_BREAK, '').substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim();
}

/**
Expand Down Expand Up @@ -1295,7 +1295,7 @@ function getIOUReportActionMessage(type, total, comment, currency, paymentType =

return [
{
html: iouMessage,
html: _.escape(iouMessage),
text: iouMessage,
isEdited: false,
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ function deleteMoneyRequest(chatReportID, iouReportID, moneyRequestAction, shoul
CONST.IOU.REPORT_ACTION_TYPE.DELETE,
amount,
moneyRequestAction.originalMessage.currency,
Str.htmlDecode(moneyRequestAction.originalMessage.comment),
moneyRequestAction.originalMessage.comment,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure this is a plain text?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where ever I look, originalMessage.comment is not present. There is only html field inside originalMessage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the console log for originalMessage.comment? Can you check where we set it, and do we set html or text

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment field simply didn't exist here when I logged. I couldn't find place where comment is set

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I think IOU messages are always in plain text. Looking at this I found another bug in getIOUReportActionMessage. The html version here

html: iouMessage,
should be the encoded version of text.

            html: _.escape(iouMessage),
            text: iouMessage,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alitoshmatov Can you apply this change as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

[],
transactionID,
'',
Expand Down
7 changes: 3 additions & 4 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Onyx from 'react-native-onyx';
import lodashGet from 'lodash/get';
import Str from 'expensify-common/lib/str';
import _ from 'underscore';
import ONYXKEYS from '../../ONYXKEYS';
import * as API from '../API';
Expand Down Expand Up @@ -54,7 +53,7 @@ function createTaskAndNavigate(currentUserEmail, parentReportID, title, descript

const optimisticReport = {
lastVisibleActionCreated: currentTime,
lastMessageText: Str.htmlDecode(lastCommentText),
lastMessageText: lastCommentText,
lastActorEmail: currentUserEmail,
lastReadTime: currentTime,
};
Expand Down Expand Up @@ -124,7 +123,7 @@ function createTaskAndNavigate(currentUserEmail, parentReportID, title, descript

const optimisticAssigneeReport = {
lastVisibleActionCreated: currentTime,
lastMessageText: Str.htmlDecode(lastAssigneeCommentText),
lastMessageText: lastAssigneeCommentText,
lastActorEmail: currentUserEmail,
lastReadTime: currentTime,
};
Expand Down Expand Up @@ -338,7 +337,7 @@ function editTaskAndNavigate(report, ownerEmail, {title, description, assignee})

const optimisticAssigneeReport = {
lastVisibleActionCreated: currentTime,
lastMessageText: Str.htmlDecode(lastAssigneeCommentText),
lastMessageText: lastAssigneeCommentText,
lastActorEmail: ownerEmail,
lastReadTime: currentTime,
};
Expand Down
3 changes: 1 addition & 2 deletions src/pages/home/report/ContextMenu/ContextMenuActions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import _ from 'underscore';
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import Str from 'expensify-common/lib/str';
import lodashGet from 'lodash/get';
import * as Expensicons from '../../../../components/Icon/Expensicons';
import * as Report from '../../../../libs/actions/Report';
Expand Down Expand Up @@ -181,7 +180,7 @@ export default [
if (!Clipboard.canSetHtml()) {
Clipboard.setString(parser.htmlToMarkdown(content));
} else {
const plainText = Str.htmlDecode(parser.htmlToText(content));
const plainText = parser.htmlToText(content);
Clipboard.setHtml(content, plainText);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionItemFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const ReportActionItemFragment = (props) => {
selectable={!DeviceCapabilities.canUseTouchScreen() || !props.isSmallScreenWidth}
style={[containsOnlyEmojis ? styles.onlyEmojisText : undefined, styles.ltr, ...props.style]}
>
{convertToLTR(Str.htmlDecode(text))}
{convertToLTR(text)}
{Boolean(props.fragment.isEdited) && (
<Text
fontSize={variables.fontSizeSmall}
Expand Down
Loading