summaryrefslogtreecommitdiff
path: root/src/tangara
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-09-03 14:36:54 +1000
committerjacqueline <me@jacqueline.id.au>2024-09-03 14:36:54 +1000
commit99a3a904e4d9cc2e4d92edbbf1ebbd0892d3918e (patch)
treebd947334eb2936ca26fa897a6d41245cdbf1c03a /src/tangara
parente6921dc0556d567557b5673a475199121898421f (diff)
downloadtangara-fw-99a3a904e4d9cc2e4d92edbbf1ebbd0892d3918e.tar.gz
Handle collation text that includes '\0'
This seems to be tickled by the ogg comment handling changes (possibly libtags doesn't actually handle this case?)
Diffstat (limited to 'src/tangara')
-rw-r--r--src/tangara/database/records.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/tangara/database/records.cpp b/src/tangara/database/records.cpp
index 6406f080..17009cd8 100644
--- a/src/tangara/database/records.cpp
+++ b/src/tangara/database/records.cpp
@@ -227,19 +227,15 @@ auto ParseIndexKey(const leveldb::Slice& slice) -> std::optional<IndexKey> {
return {};
}
- std::istringstream in(key_data.substr(header_length + 1));
- std::stringbuf buffer{};
+ key_data = key_data.substr(header_length + 1);
+ size_t last_sep = key_data.find_last_of('\0');
- // FIXME: what if the item contains a '\0'? Probably we make a big mess.
- in.get(buffer, kFieldSeparator);
- if (buffer.str().size() > 0) {
- result.item = buffer.str();
+ if (last_sep > 0) {
+ result.item = key_data.substr(0, last_sep);
}
- std::string id_str =
- key_data.substr(header_length + 1 + buffer.str().size() + 1);
- if (id_str.size() > 0) {
- result.track = BytesToTrackId(id_str);
+ if (last_sep + 1 < key_data.size()) {
+ result.track = BytesToTrackId(key_data.substr(last_sep + 1));
}
return result;