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
Conversation
@@ -714,6 +715,10 @@ func parseMulti(parser tagcommon.Info, setting MultiValueSetting, getMulti func( | |||
default: | |||
parts = []string{get(parser)} | |||
} | |||
// trim potential empty strings from delimited results |
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
for i := range parts {
parts[i] = strings.TrimSpace(parts[i])
}
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!
@@ -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 comment
The 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
(later this may want to be the first grapheme cluster)
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)
}
thanks for the fix! just added 2 comments |
hey i think the changes were safe enough so i just authored you and commited them. let me know if that's okay. thanks! |
…acent delimiters closes #448 Co-authored-by: Chris Hayes <chayes@interrobang.sh>
Hi! This project is pretty great, thanks for it.
After scanning an initial set of albums, attempts to bring up my artist list (via both Tempo/Subsonic) would fail with a network error. On reviewing gonic logs, I found the following:
After some further tests I isolated this down to a single album and artist - N O Ć [EP]' by DON'T//BE// ⚜⚜⚜ - the failure resulting from the double-slashes in the artist name. The current multiParser function (with configured '/' delim) will split the double-slash into an empty string. When this
""
reaches the unicode index check (lowerUDecOrHash), it panics with the above and breaks the response.This PR implements two remediations:
While the above restores the artist index, this particular artist will still be split into three separate objects (albeit functionally). Perhaps not ideal, but also an extremely niche case that could likely be addressed at a later time. I'd otherwise expect this to be seen if someone had a typo in their tags.