diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-26 14:30:55 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-26 14:31:02 +0200 |
commit | 41a06564d12be6888e0b9e7dee6b809169e5c42e (patch) | |
tree | 7557e5701e50b73d8a57cc37f4f6d0145196a17c | |
parent | a4190dd0a5aaedb2fef1e14518a1d7d3c6448b1a (diff) |
Don't apply MIME hooks on downloaded files
-rw-r--r-- | src/gmrequest.c | 4 | ||||
-rw-r--r-- | src/gmrequest.h | 1 | ||||
-rw-r--r-- | src/media.c | 9 | ||||
-rw-r--r-- | src/media.h | 2 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 10 |
5 files changed, 17 insertions, 9 deletions
diff --git a/src/gmrequest.c b/src/gmrequest.c index 9cdd627e..f4d770ab 100644 --- a/src/gmrequest.c +++ b/src/gmrequest.c | |||
@@ -494,6 +494,10 @@ void deinit_GmRequest(iGmRequest *d) { | |||
494 | delete_Mutex(d->mtx); | 494 | delete_Mutex(d->mtx); |
495 | } | 495 | } |
496 | 496 | ||
497 | void enableFilters_GmRequest(iGmRequest *d, iBool enable) { | ||
498 | d->isFilterEnabled = enable; | ||
499 | } | ||
500 | |||
497 | void setUrl_GmRequest(iGmRequest *d, const iString *url) { | 501 | void setUrl_GmRequest(iGmRequest *d, const iString *url) { |
498 | set_String(&d->url, urlFragmentStripped_String(url)); | 502 | set_String(&d->url, urlFragmentStripped_String(url)); |
499 | /* Encode hostname to Punycode here because we want to submit the Punycode domain name | 503 | /* Encode hostname to Punycode here because we want to submit the Punycode domain name |
diff --git a/src/gmrequest.h b/src/gmrequest.h index bd340cf1..6d4eb2f8 100644 --- a/src/gmrequest.h +++ b/src/gmrequest.h | |||
@@ -64,6 +64,7 @@ iDeclareNotifyFunc(GmRequest, Finished) | |||
64 | iDeclareAudienceGetter(GmRequest, updated) | 64 | iDeclareAudienceGetter(GmRequest, updated) |
65 | iDeclareAudienceGetter(GmRequest, finished) | 65 | iDeclareAudienceGetter(GmRequest, finished) |
66 | 66 | ||
67 | void enableFilters_GmRequest (iGmRequest *, iBool enable); | ||
67 | void setUrl_GmRequest (iGmRequest *, const iString *url); | 68 | void setUrl_GmRequest (iGmRequest *, const iString *url); |
68 | void submit_GmRequest (iGmRequest *); | 69 | void submit_GmRequest (iGmRequest *); |
69 | void cancel_GmRequest (iGmRequest *); | 70 | void cancel_GmRequest (iGmRequest *); |
diff --git a/src/media.c b/src/media.c index 000214b2..b329ec03 100644 --- a/src/media.c +++ b/src/media.c | |||
@@ -475,11 +475,13 @@ static void finished_MediaRequest_(iAnyObject *obj) { | |||
475 | postCommandf_App("media.finished link:%u request:%p", d->linkId, d); | 475 | postCommandf_App("media.finished link:%u request:%p", d->linkId, d); |
476 | } | 476 | } |
477 | 477 | ||
478 | void init_MediaRequest(iMediaRequest *d, iDocumentWidget *doc, unsigned int linkId, const iString *url) { | 478 | void init_MediaRequest(iMediaRequest *d, iDocumentWidget *doc, unsigned int linkId, |
479 | const iString *url, iBool enableFilters) { | ||
479 | d->doc = doc; | 480 | d->doc = doc; |
480 | d->linkId = linkId; | 481 | d->linkId = linkId; |
481 | d->req = new_GmRequest(certs_App()); | 482 | d->req = new_GmRequest(certs_App()); |
482 | setUrl_GmRequest(d->req, url); | 483 | setUrl_GmRequest(d->req, url); |
484 | enableFilters_GmRequest(d->req, enableFilters); | ||
483 | iConnect(GmRequest, d->req, updated, d, updated_MediaRequest_); | 485 | iConnect(GmRequest, d->req, updated, d, updated_MediaRequest_); |
484 | iConnect(GmRequest, d->req, finished, d, finished_MediaRequest_); | 486 | iConnect(GmRequest, d->req, finished, d, finished_MediaRequest_); |
485 | submit_GmRequest(d->req); | 487 | submit_GmRequest(d->req); |
@@ -492,6 +494,7 @@ void deinit_MediaRequest(iMediaRequest *d) { | |||
492 | } | 494 | } |
493 | 495 | ||
494 | iDefineObjectConstructionArgs(MediaRequest, | 496 | iDefineObjectConstructionArgs(MediaRequest, |
495 | (iDocumentWidget *doc, unsigned int linkId, const iString *url), | 497 | (iDocumentWidget *doc, unsigned int linkId, const iString *url, |
496 | doc, linkId, url) | 498 | iBool enableFilters), |
499 | doc, linkId, url, enableFilters) | ||
497 | iDefineClass(MediaRequest) | 500 | iDefineClass(MediaRequest) |
diff --git a/src/media.h b/src/media.h index ece60630..7cc941d0 100644 --- a/src/media.h +++ b/src/media.h | |||
@@ -80,4 +80,4 @@ struct Impl_MediaRequest { | |||
80 | }; | 80 | }; |
81 | 81 | ||
82 | iDeclareObjectConstructionArgs(MediaRequest, iDocumentWidget *doc, unsigned int linkId, | 82 | iDeclareObjectConstructionArgs(MediaRequest, iDocumentWidget *doc, unsigned int linkId, |
83 | const iString *url) | 83 | const iString *url, iBool enableFilters) |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 6f47a26e..c953e0f3 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -1308,10 +1308,10 @@ static iMediaRequest *findMediaRequest_DocumentWidget_(const iDocumentWidget *d, | |||
1308 | return NULL; | 1308 | return NULL; |
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | static iBool requestMedia_DocumentWidget_(iDocumentWidget *d, iGmLinkId linkId) { | 1311 | static iBool requestMedia_DocumentWidget_(iDocumentWidget *d, iGmLinkId linkId, iBool enableFilters) { |
1312 | if (!findMediaRequest_DocumentWidget_(d, linkId)) { | 1312 | if (!findMediaRequest_DocumentWidget_(d, linkId)) { |
1313 | const iString *mediaUrl = absoluteUrl_String(d->mod.url, linkUrl_GmDocument(d->doc, linkId)); | 1313 | const iString *mediaUrl = absoluteUrl_String(d->mod.url, linkUrl_GmDocument(d->doc, linkId)); |
1314 | pushBack_ObjectList(d->media, iClob(new_MediaRequest(d, linkId, mediaUrl))); | 1314 | pushBack_ObjectList(d->media, iClob(new_MediaRequest(d, linkId, mediaUrl, enableFilters))); |
1315 | invalidate_DocumentWidget_(d); | 1315 | invalidate_DocumentWidget_(d); |
1316 | return iTrue; | 1316 | return iTrue; |
1317 | } | 1317 | } |
@@ -1410,7 +1410,7 @@ static iBool fetchNextUnfetchedImage_DocumentWidget_(iDocumentWidget *d) { | |||
1410 | if (isMediaLink_GmDocument(d->doc, run->linkId) && | 1410 | if (isMediaLink_GmDocument(d->doc, run->linkId) && |
1411 | linkFlags & imageFileExtension_GmLinkFlag && | 1411 | linkFlags & imageFileExtension_GmLinkFlag && |
1412 | ~linkFlags & content_GmLinkFlag && ~linkFlags & permanent_GmLinkFlag ) { | 1412 | ~linkFlags & content_GmLinkFlag && ~linkFlags & permanent_GmLinkFlag ) { |
1413 | if (requestMedia_DocumentWidget_(d, run->linkId)) { | 1413 | if (requestMedia_DocumentWidget_(d, run->linkId, iTrue)) { |
1414 | return iTrue; | 1414 | return iTrue; |
1415 | } | 1415 | } |
1416 | } | 1416 | } |
@@ -1685,7 +1685,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1685 | const iGmLinkId linkId = d->contextLink->linkId; | 1685 | const iGmLinkId linkId = d->contextLink->linkId; |
1686 | setDownloadUrl_Media( | 1686 | setDownloadUrl_Media( |
1687 | media_GmDocument(d->doc), linkId, linkUrl_GmDocument(d->doc, linkId)); | 1687 | media_GmDocument(d->doc), linkId, linkUrl_GmDocument(d->doc, linkId)); |
1688 | requestMedia_DocumentWidget_(d, linkId); | 1688 | requestMedia_DocumentWidget_(d, linkId, iFalse /* no filters */); |
1689 | redoLayout_GmDocument(d->doc); /* inline downloader becomes visible */ | 1689 | redoLayout_GmDocument(d->doc); /* inline downloader becomes visible */ |
1690 | updateVisible_DocumentWidget_(d); | 1690 | updateVisible_DocumentWidget_(d); |
1691 | invalidate_DocumentWidget_(d); | 1691 | invalidate_DocumentWidget_(d); |
@@ -2583,7 +2583,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
2583 | further to do. */ | 2583 | further to do. */ |
2584 | return iTrue; | 2584 | return iTrue; |
2585 | } | 2585 | } |
2586 | if (!requestMedia_DocumentWidget_(d, linkId)) { | 2586 | if (!requestMedia_DocumentWidget_(d, linkId, iTrue)) { |
2587 | if (linkFlags & content_GmLinkFlag) { | 2587 | if (linkFlags & content_GmLinkFlag) { |
2588 | /* Dismiss shown content on click. */ | 2588 | /* Dismiss shown content on click. */ |
2589 | setData_Media(media_GmDocument(d->doc), | 2589 | setData_Media(media_GmDocument(d->doc), |