Skip to content
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

Fix loading avatars from Dropbox due to URLs containing parameters #634

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading