From 4c4f4258b3425d63eae4e31ada3ca08b1e08b941 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Wed, 28 Oct 2020 08:36:53 +0200 Subject: Reporting TLS/SSL errors A proper error page is now shown if there is an error during the TLS request. --- lib/the_Foundation | 2 +- src/gmdocument.c | 9 ++++++++- src/gmdocument.h | 1 + src/gmutil.c | 2 +- src/ui/documentwidget.c | 3 +++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/the_Foundation b/lib/the_Foundation index ce566a89..b0575cae 160000 --- a/lib/the_Foundation +++ b/lib/the_Foundation @@ -1 +1 @@ -Subproject commit ce566a8986f0780d7fc098af1dbf4c62525c7537 +Subproject commit b0575caee3406571f4c100338f1f6322369067a4 diff --git a/src/gmdocument.c b/src/gmdocument.c index b8de304f..50733252 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c @@ -63,6 +63,7 @@ struct Impl_GmDocument { iString url; /* for resolving relative links */ iString localHost; int forceBreakWidth; /* force breaks on very long preformatted lines */ + iBool siteBannerEnabled; iInt2 size; iArray layout; /* contents of source, laid out in document space */ iPtrArray links; @@ -295,7 +296,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { iRangecc preAltText = iNullRange; int preFont = preformatted_FontId; iBool enableIndents = iFalse; - iBool addSiteBanner = iTrue; + iBool addSiteBanner = d->siteBannerEnabled; enum iGmLineType prevType = text_GmLineType; if (d->format == plainText_GmDocumentFormat) { isPreformat = iTrue; @@ -592,6 +593,7 @@ void init_GmDocument(iGmDocument *d) { init_String(&d->source); init_String(&d->url); init_String(&d->localHost); + d->siteBannerEnabled = iTrue; d->size = zero_I2(); init_Array(&d->layout, sizeof(iGmRun)); init_PtrArray(&d->links); @@ -632,6 +634,7 @@ void reset_GmDocument(iGmDocument *d) { clear_String(&d->url); clear_String(&d->localHost); d->themeSeed = 0; + d->siteBannerEnabled = iTrue; } static void setDerivedThemeColors_(enum iGmDocumentTheme theme) { @@ -1055,6 +1058,10 @@ void setFormat_GmDocument(iGmDocument *d, enum iGmDocumentFormat format) { d->format = format; } +void setSiteBannerEnabled_GmDocument(iGmDocument *d, iBool siteBannerEnabled) { + d->siteBannerEnabled = siteBannerEnabled; +} + void setWidth_GmDocument(iGmDocument *d, int width, int forceBreakWidth) { d->forceBreakWidth = forceBreakWidth; d->size.x = width; diff --git a/src/gmdocument.h b/src/gmdocument.h index f27446ab..84af3c98 100644 --- a/src/gmdocument.h +++ b/src/gmdocument.h @@ -107,6 +107,7 @@ enum iGmDocumentFormat { void setThemeSeed_GmDocument (iGmDocument *, const iBlock *seed); void setFormat_GmDocument (iGmDocument *, enum iGmDocumentFormat format); +void setSiteBannerEnabled_GmDocument(iGmDocument *, iBool siteBannerEnabled); void setWidth_GmDocument (iGmDocument *, int width, int forceBreakWidth); void redoLayout_GmDocument (iGmDocument *); void setUrl_GmDocument (iGmDocument *, const iString *url); diff --git a/src/gmutil.c b/src/gmutil.c index 5f09a176..4b144097 100644 --- a/src/gmutil.c +++ b/src/gmutil.c @@ -240,7 +240,7 @@ static const struct { { tlsFailure_GmStatusCode, { 0x1f5a7, /* networked computers */ "Network/TLS Failure", - "We could not communicate with the requested host." } }, + "Failed to communicate with the host. Here is the error message:" } }, { temporaryFailure_GmStatusCode, { 0x1f50c, /* electric plug */ "Temporary Failure", diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 60e08459..3f08e678 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -682,6 +682,7 @@ static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode const iGmError *msg = get_GmError(code); appendChar_String(src, msg->icon ? msg->icon : 0x2327); /* X in a box */ appendFormat_String(src, " %s\n%s", msg->title, msg->info); + iBool useBanner = iTrue; if (meta) { switch (code) { case nonGeminiRedirect_GmStatusCode: @@ -689,6 +690,7 @@ static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode appendFormat_String(src, "\n=> %s\n", cstr_String(meta)); break; case tlsFailure_GmStatusCode: + useBanner = iFalse; /* valid data wasn't received from host */ appendFormat_String(src, "\n\n>%s\n", cstr_String(meta)); break; case failedToOpenFile_GmStatusCode: @@ -714,6 +716,7 @@ static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode break; } } + setSiteBannerEnabled_GmDocument(d->doc, useBanner); setSource_DocumentWidget_(d, src); updateTheme_DocumentWidget_(d); init_Anim(&d->scrollY, 0); -- cgit v1.2.3