Skip to content

Commit

Permalink
Merge pull request #634 from daleglass-overte/fix-dropbox-avatars
Browse files Browse the repository at this point in the history
Fix loading avatars from Dropbox due to URLs containing parameters
  • Loading branch information
ksuprynowicz authored Sep 18, 2023
2 parents 3755381 + 0fb11f1 commit 5526e75
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions libraries/model-serializers/src/FSTReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include <NetworkingConstants.h>
#include <SharedUtil.h>


const QStringList SINGLE_VALUE_PROPERTIES{"name", "filename", "texdir", "script", "comment"};

hifi::VariantMultiHash FSTReader::parseMapping(QIODevice* device) {
hifi::VariantMultiHash properties;

Expand All @@ -32,9 +35,25 @@ hifi::VariantMultiHash FSTReader::parseMapping(QIODevice* device) {
if (sections.size() < 2) {
continue;
}

// We can have URLs like:
// filename = https://www.dropbox.com/scl/fi/xxx/avatar.fbx?rlkey=xxx&dl=1\n
// These confuse the parser due to the presence of = in the URL.
//
// SINGLE_VALUE_PROPERTIES contains a list of things that may be URLs or contain an =
// for some other reason, and that we know for sure contain only a single value after
// the first =.
//
// Really though, we should just use JSON instead.
QByteArray name = sections.at(0).trimmed();
if (sections.size() == 2) {
properties.insert(name, sections.at(1).trimmed());
bool isSingleValue = SINGLE_VALUE_PROPERTIES.contains(name);

if (sections.size() == 2 || isSingleValue) {
// As per the above, we can have '=' signs inside of URLs, so instead of
// using the split string, just use everything after the first '='.

QString value = line.mid(line.indexOf("=")+1).trimmed();
properties.insert(name, value);
} else if (sections.size() == 3) {
QVariantHash heading = properties.value(name).toHash();
heading.insert(sections.at(1).trimmed(), sections.at(2).trimmed());
Expand Down

0 comments on commit 5526e75

Please sign in to comment.