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
Bugfix: Remediation for Panic! at the Parser #448
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -518,6 +518,11 @@ func getMusicFolder(musicPaths []MusicPath, p params.Params) string { | |
} | ||
|
||
func lowerUDecOrHash(in string) string { | ||
defer func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think i would prefer to just check the length of the string is 0 instead of catching all panics also, i just noticed that the previous implementation has a subtle bug too. it gets the first byte of the string, where really we probably want the first codepoint/rune how about: func lowerUDecOrHash(in string) string {
inRunes := []rune(in)
if len(inRunes) == 0 {
return ""
}
lower := unicode.ToLower(inRunes[0])
if !unicode.IsLetter(lower) {
return "#"
}
return string(lower)
} |
||
if err := recover(); err != nil { | ||
log.Println("unable to index parsed object:", err) | ||
} | ||
}() | ||
lower := unicode.ToLower(rune(in[0])) | ||
if !unicode.IsLetter(lower) { | ||
return "#" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it would make sense to do this after the
below
so that we trim, then delete. that we we find more matches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, you are correct, thanks!