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

🐛[RUMF-716] fix invalid action name #557

Merged
merged 2 commits into from
Oct 12, 2020
Merged

Conversation

bcaudan
Copy link
Contributor

@bcaudan bcaudan commented Oct 9, 2020

Motivation

Some UTF-8 characters can be composed of a pair of "surrogate" characters.

more details: MDN#encodeURIComponent

Changes

Ensure that our string truncate don't make invalid string by keeping only the first part of the pair.

Testing

unit test


I have gone over the contributing documentation.

Some UTF-8 characters can be composed of a pair of "surrogate" characters.
Ensure that our string truncate don't make invalid string by keeping only the first part of the pair.

more details https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
@bcaudan bcaudan requested a review from a team as a code owner October 9, 2020 15:51
Copy link
Member

@BenoitZugmeyer BenoitZugmeyer left a comment

Choose a reason for hiding this comment

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

Good catch!

I think that testing if the character at the ending position is part of a surrogate pair would be nicer.

Something like:

  // tslint:disable-next-line: no-bitwise
  if ((candidate.charCodeAt(length - 1) & 0xf800) === 0xd800) {
    return candidate.slice(0, length + 1)
  }
  return candidate.slice(0, length)

WDYT?

@codecov-io
Copy link

Codecov Report

Merging #557 into master will increase coverage by 0.37%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #557      +/-   ##
==========================================
+ Coverage   89.31%   89.69%   +0.37%     
==========================================
  Files          38       38              
  Lines        2265     2270       +5     
  Branches      473      474       +1     
==========================================
+ Hits         2023     2036      +13     
+ Misses        242      234       -8     
Impacted Files Coverage Δ
packages/core/src/utils.ts 87.70% <100.00%> (+0.35%) ⬆️
packages/rum/src/getActionNameFromElement.ts 87.38% <100.00%> (ø)
packages/rum/src/performanceCollection.ts 68.57% <0.00%> (+1.42%) ⬆️
packages/rum/src/parentContexts.ts 100.00% <0.00%> (+1.75%) ⬆️
packages/rum/src/rum.ts 92.70% <0.00%> (+4.37%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 61d2252...4dc55a9. Read the comment docs.

@bcaudan bcaudan merged commit c1f4b05 into master Oct 12, 2020
@bcaudan bcaudan deleted the bcaudan/truncate-valid branch October 12, 2020 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants