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

Invalid multibyte support #951

Closed
alex-dev opened this issue Dec 9, 2022 · 1 comment · Fixed by #952
Closed

Invalid multibyte support #951

alex-dev opened this issue Dec 9, 2022 · 1 comment · Fixed by #952
Assignees
Labels
bug Something isn't working right

Comments

@alex-dev
Copy link

alex-dev commented Dec 9, 2022

Version(s) affected

2.3.7

Description

If mb_internal_encoding() is anything but UTF-8 and a multibyte character is used before an inline link, output will be garbage such as ABC ÀÀ [label](url) -> ABC ÀÀ [l[bel](url).

Bug is caused by a mb_strlen call not passing encoding in InlineParserEngine.

A quick regex search found 11 similar calls. Some may be safe because they don't expect multibyte input (URI cannot be multibyte in markdown). In this case they should be converted to non multibyte calls to avoid the confusion.

How to reproduce

mb_internal_encoding('iso-8859-1');
(new CommonMarkConverter)->convert('AAA ÀÀ [label][(https://url)');
@colinodell colinodell self-assigned this Dec 10, 2022
@colinodell colinodell added the bug Something isn't working right label Dec 10, 2022
colinodell added a commit that referenced this issue Dec 10, 2022
@colinodell
Copy link
Member

Thanks for the report! I've fixed this via #952 (released as version 2.3.8) which also includes a custom phpstan rule to ensure we don't forget to pass the encoding in the future :)

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

Successfully merging a pull request may close this issue.

2 participants