Skip to content
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
2 changes: 2 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,8 @@ const CONST = {
DATE_TIME_FORMAT: /^\d{2}-\d{2} \d{2}:\d{2} [AP]M$/,
ATTACHMENT_ROUTE: /\/r\/(\d*)\/attachment/,
ILLEGAL_FILENAME_CHARACTERS: /\/|<|>|\*|"|:|\?|\\|\|/g,

ENCODE_PERCENT_CHARACTER: /%(25)+/g,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will match things like %252525 is that correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, correct

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, I see why now, a bit of an edge case but why not lol

},

PRONOUNS: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import ValidateCodeForm from './ValidateCodeForm';
import ROUTES from '../../../../ROUTES';
import FullscreenLoadingIndicator from '../../../../components/FullscreenLoadingIndicator';
import FullPageNotFoundView from '../../../../components/BlockingViews/FullPageNotFoundView';
import CONST from '../../../../CONST';

const propTypes = {
/* Onyx Props */
Expand Down Expand Up @@ -131,7 +132,22 @@ class ContactMethodDetailsPage extends Component {
* @returns {string}
*/
getContactMethod() {
return decodeURIComponent(lodashGet(this.props.route, 'params.contactMethod'));
const contactMethod = lodashGet(this.props.route, 'params.contactMethod');

// We find the number of times the url is encoded based on the last % sign and remove them.
const lastPercentIndex = contactMethod.lastIndexOf('%');
const encodePercents = contactMethod.substring(lastPercentIndex).match(new RegExp('25', 'g'));
let numberEncodePercents = encodePercents ? encodePercents.length : 0;
const beforeAtSign = contactMethod.substring(0, lastPercentIndex).replace(CONST.REGEX.ENCODE_PERCENT_CHARACTER, (match) => {
if (numberEncodePercents > 0) {
numberEncodePercents--;
return '%';
}
return match;
});
const afterAtSign = contactMethod.substring(lastPercentIndex).replace(CONST.REGEX.ENCODE_PERCENT_CHARACTER, '%');

return decodeURIComponent(beforeAtSign + afterAtSign);
}

/**
Expand Down