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

Fixes bugs related to unicode support in polynomial-hash functions #304

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

dubzzz
Copy link
Contributor

@dubzzz dubzzz commented Feb 14, 2019

Details:

This Pull Request fixes bugs related to unicode support in polynomial-hash functions:

  • Method charToNumber of PolynomialHash was wrongly computed the code point value of a character: codePointAt is already aware of surrogate pairs (which is not the case of charCodeAt)
  • Method roll of PolynomialHash ignored unicode characters totally
  • SimplePolynomialHash was not aware of unicode

How did I find it?

Originally I wanted to check how I could rewrite the existing for-loop based tests into something based on property based. Then it clearly appeared that the test can be simplified given the switch to property based: roll(hash(XYZ), XYZ, YZA) === hash(YZA) whatever the values of X, Y, Z, A.

The final version of the test can be read as follow:
For any A single character, B single character and W string,
roll(hash(A + W), A + W, W + B) === hash(W + B)

As a side note, I strongly believe that adding such kind of tests would highly help to detect such bugs easily. Up to now it has detected the following: #100, #101, #102, #110 and #129.

And also #305, #306, #307, #308.

@codecov
Copy link

codecov bot commented Feb 14, 2019

Codecov Report

Merging #304 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #304   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files         147    147           
  Lines        2591   2588    -3     
  Branches      432    431    -1     
=====================================
- Hits         2591   2588    -3
Impacted Files Coverage Δ
...yptography/polynomial-hash/SimplePolynomialHash.js 100% <100%> (ø) ⬆️
...hms/cryptography/polynomial-hash/PolynomialHash.js 100% <100%> (ø) ⬆️

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 1f39355...bd7d103. Read the comment docs.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@dubzzz
Copy link
Contributor Author

dubzzz commented Mar 3, 2019

@trekhleb Any updates? I can rebase the branch if needed

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.

None yet

1 participant