mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 07:29:14 +01:00
sync: drop non-finite replay gain values at the parse boundary
`toFloatOrNull` accepts `"Infinity"`, `"NaN"` and overflowing literals like `"1e40"`, so a server (or a corrupt tag it read) could put a non-finite gain or peak into the library. An infinite peak later caps the applied gain at negative infinity, i.e. silence; an infinite gain clips every sample to full scale. Nothing consumes these columns yet, so this is only about not storing values that cannot mean anything.
This commit is contained in:
@@ -245,7 +245,7 @@ internal fun Attributes.attr(name: String): String = getValue(name) ?: ""
|
||||
|
||||
internal fun Attributes.longAttr(name: String): Long? = attr(name).takeIf { it.isNotEmpty() }?.toLongOrNull()
|
||||
|
||||
internal fun Attributes.floatAttr(name: String): Float? = attr(name).takeIf { it.isNotEmpty() }?.toFloatOrNull()
|
||||
internal fun Attributes.floatAttr(name: String): Float? = attr(name).takeIf { it.isNotEmpty() }?.toFloatOrNull()?.takeIf { it.isFinite() }
|
||||
|
||||
internal fun Attributes.dateAttr(name: String): Long? = attr(name).takeIf { it.isNotEmpty() }?.let(IsoDate::parse)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user