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

Breaks when string contains a zero-width character #2

Closed
carbontwelve opened this issue Feb 13, 2018 · 2 comments
Closed

Breaks when string contains a zero-width character #2

carbontwelve opened this issue Feb 13, 2018 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@carbontwelve
Copy link
Contributor

carbontwelve commented Feb 13, 2018

When using the isConfusable method with the input string www.microsоft.com and a preferredAliases of ['latin']. The following error is returned: Undefined Index: Confusable.php:146.

This is because the input string contains the zero-width character \u65279 - incidentally this zero width character gets correctly parsed as the common alias however on line 146 of Confusable.php it's essentially a empty string and the array key lookup fails on the index not existing.

If the index does exist in the json source, then maybe it needs converting so the index is the escaped unicode in ASCII string form - if so this can be folded into #1.

@carbontwelve carbontwelve added the bug Something isn't working label Feb 13, 2018
@carbontwelve carbontwelve changed the title Undefined Index: Confusable.php:146 Breaks when string contains a zero-width character Feb 13, 2018
carbontwelve added a commit that referenced this issue Feb 13, 2018
@carbontwelve carbontwelve self-assigned this Feb 14, 2018
@carbontwelve carbontwelve modified the milestones: 1.1.0, 1.0.1 Feb 14, 2018
carbontwelve added a commit that referenced this issue Feb 14, 2018
@carbontwelve
Copy link
Contributor Author

Looks as though the port was 100%; the Python source uses the dictionary get method on the loaded json source which returns a sane default.

By wrapping the assignment of $found on line 146 (now 148 after comments) with an isset check and assigning an empty array by default this issue is fixed.

carbontwelve added a commit that referenced this issue Feb 14, 2018
* Adding failing test for #2 TDD

* Fix for #2
@carbontwelve
Copy link
Contributor Author

Fixed by #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant