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

Fix "not a character boundary" panic in missing_copyright_notice #7015

Closed
MichaReiser opened this issue Aug 31, 2023 · 3 comments
Closed

Fix "not a character boundary" panic in missing_copyright_notice #7015

MichaReiser opened this issue Aug 31, 2023 · 3 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Contributions especially welcome

Comments

@MichaReiser
Copy link
Member

The missing copyright notice only looks at the 1024 first bytes. However, this can go wrong for unicode text if the 1024 byte is not a character boundary (because it is a multibyte character).

let contents = if locator.len() < 1024 {
locator.contents()
} else {
locator.up_to(TextSize::from(1024))
};

Fix: Use is_char_boundary to find a valid char boundary close to 1024.

locator.contents().is_char_boundary(1024)
@MichaReiser MichaReiser added bug Something isn't working good first issue Good for newcomers help wanted Contributions especially welcome labels Aug 31, 2023
@MichaReiser MichaReiser changed the title Fix potential "not a character boundary" panic in missing_copyright_notice Fix "not a character boundary" panic in missing_copyright_notice Aug 31, 2023
@WindowGenerator
Copy link
Contributor

@MichaReiser Hello. Can I solve this bug?

@MichaReiser
Copy link
Member Author

@WindowGenerator sure. #7012 or #7027 both contain a code snipped that triggers the error and you may want to use as a test case.

WindowGenerator added a commit to WindowGenerator/ruff that referenced this issue Aug 31, 2023
WindowGenerator added a commit to WindowGenerator/ruff that referenced this issue Aug 31, 2023
WindowGenerator added a commit to WindowGenerator/ruff that referenced this issue Sep 1, 2023
WindowGenerator added a commit to WindowGenerator/ruff that referenced this issue Sep 1, 2023
WindowGenerator added a commit to WindowGenerator/ruff that referenced this issue Sep 1, 2023
@qarmin
Copy link

qarmin commented Sep 2, 2023

This is fixed and can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Contributions especially welcome
Projects
None yet
Development

No branches or pull requests

3 participants