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

archive: fix potential panic in bsd_filename_length #335

Merged
merged 1 commit into from
Oct 10, 2022

Conversation

nathaniel-daniel
Copy link
Contributor

@nathaniel-daniel nathaniel-daniel commented Oct 9, 2022

Fix for #328. Direct indexing is removed in favor of strip_prefix.

Copy link
Owner

@m4b m4b left a comment

Choose a reason for hiding this comment

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

LGTM thanks for this!

@@ -164,8 +164,8 @@ impl<'a> Member<'a> {
fn bsd_filename_length(name: &str) -> Option<usize> {
use core::str::FromStr;

if name.len() > 3 && &name[0..3] == "#1/" {
let trimmed_name = &name[3..].trim_end_matches(' ');
if let Some(name) = name.strip_prefix("#1/") {
Copy link
Owner

Choose a reason for hiding this comment

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

This is awesome, did not know about this method :) much nicer now

@@ -620,6 +620,7 @@ mod tests {
assert_eq!(Member::bsd_filename_length("#2/1"), None);
assert_eq!(Member::bsd_filename_length(INDEX_NAME), None);
assert_eq!(Member::bsd_filename_length(NAME_INDEX_NAME), None);
assert_eq!(Member::bsd_filename_length("👺"), None);
Copy link
Owner

Choose a reason for hiding this comment

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

And thanks for adding test

@m4b m4b merged commit 761ffd8 into m4b:master Oct 10, 2022
@nathaniel-daniel nathaniel-daniel deleted the issue-328 branch October 11, 2022 23:04
@m4b
Copy link
Owner

m4b commented Oct 24, 2022

released in 0.6

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.

2 participants