Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F114642
D104.1732569259.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D104.1732569259.diff
View Options
diff --git a/src/contents/ui/KazvIOMenu.qml b/src/contents/ui/KazvIOMenu.qml
--- a/src/contents/ui/KazvIOMenu.qml
+++ b/src/contents/ui/KazvIOMenu.qml
@@ -57,6 +57,7 @@
[MK.KazvIOBaseJob.WriteFileError, 'kazv-io-failure-detail-write-file-error'],
[MK.KazvIOBaseJob.KIOError, 'kazv-io-failure-detail-network-error'],
[MK.KazvIOBaseJob.HashError, 'kazv-io-failure-detail-hash-error'],
+ [MK.KazvIOBaseJob.ResponseError, 'kazv-io-failure-detail-response-error'],
[MK.KazvIOBaseJob.KazvError, 'kazv-io-failure-detail-kazv-error']
])
resultMsg.text = l10n.get(resultL10nId, {detail: l10n.get(detailL10nId.get(ec))})
diff --git a/src/kazv-io-job.hpp b/src/kazv-io-job.hpp
--- a/src/kazv-io-job.hpp
+++ b/src/kazv-io-job.hpp
@@ -58,6 +58,11 @@
* Error caused by hash error
*/
HashError,
+ /**
+ * Error caused by invalid response.
+ * KIO reported no error, but got an invalid JSON response.
+ */
+ ResponseError,
/**
* Errors caused by bad code, means the bug is somewhere.
*/
diff --git a/src/kazv-io-job.cpp b/src/kazv-io-job.cpp
--- a/src/kazv-io-job.cpp
+++ b/src/kazv-io-job.cpp
@@ -295,9 +295,22 @@
return;
}
- auto j = nlohmann::json::parse(m_d->response.toStdString());
- auto mxcUri = QString::fromStdString(j["content_uri"].get<std::string>());
-
+ nlohmann::json j{};
+ try {
+ j = nlohmann::json::parse(m_d->response.toStdString());
+ } catch(...) {
+ emitResult(ResponseError);
+ qDebug() << "Get a invaild response from server.";
+ return;
+ }
+ QString mxcUri{};
+ if (j.contains("content_uri")) {
+ mxcUri = QString::fromStdString(j["content_uri"].get<std::string>());
+ } else {
+ emitResult(ResponseError);
+ qDebug() << "There is no \"content_uri\" field in response.";
+ return;
+ }
auto shouldSendMessage = !!m_d->room;
if (shouldSendMessage) {
auto aes = this->aes();
diff --git a/src/l10n/en/100-ui.ftl b/src/l10n/en/100-ui.ftl
--- a/src/l10n/en/100-ui.ftl
+++ b/src/l10n/en/100-ui.ftl
@@ -209,6 +209,7 @@
kazv-io-failure-detail-open-file-error = Open file error
kazv-io-failure-detail-write-file-error = Write file error
kazv-io-failure-detail-hash-error = Hash check error
+kazv-io-failure-detail-response-error = Get an invalid response
kazv-io-failure-detail-kazv-error = Unknow Error, please report this as bug.
kazv-io-upload-failure-prompt = Upload failure: { $detail }
kazv-io-downloading-prompt = Downloading: { $fileName }
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 1:14 PM (10 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40321
Default Alt Text
D104.1732569259.diff (2 KB)
Attached To
Mode
D104: Fix crash when upload failed
Attached
Detach File
Event Timeline
Log In to Comment