Lagrange [work/v1.11]

Added a preference for maximum URL size

=> 672a534a044d811aa57e927288de50360882ac54

diff --git a/po/en.po b/po/en.po
index 100cfb9f..aae67ff0 100644
--- a/po/en.po
+++ b/po/en.po
@@ -1670,6 +1670,9 @@ msgstr "Wrap plain text:"
 msgid "prefs.decodeurls"
 msgstr "Decode URLs:"
 
+msgid "prefs.urlsize"
+msgstr "Maximum URL size:"
+
 msgid "prefs.cachesize"
 msgstr "Cache size:"
 
diff --git a/res/about/help.gmi b/res/about/help.gmi
index 93bc6a05..5bf77a76 100644
--- a/res/about/help.gmi
+++ b/res/about/help.gmi
@@ -106,10 +106,15 @@ The type and destination of a link are indicated by the link's icon and color: 
 
 Link colors remain the same regardless of which color theme is being used for page content. (Color themes are discussed in the Customization section.)
 
-When you move the mouse cursor over a link, additional information will appear: the destination domain, with the URL scheme shown for non-Gemini links, and the date of the last visit to the URL.
+The "Show URL on hover" option can be enabled in Preferences to show additional information when you move the mouse cursor over a link: the destination domain, URL scheme for non-Gemini links, date of the last visit to the URL, and the identity that will be used when opening the link.
 
 If a link would normally use the default ➤ icon but there is an Emoji at the beginning of the link label, that Emoji is used as the link icon instead. In these cases, you can always assume that the link is a Gemini link whose destination is the same domain that you're currently on.
 
+The "Network" tab of Preferences has a few settings that affect the presentation of links and URLs in general:
+
+* "Decode URLs" causes percent-coding to be decoded for the user interface, so one can see international characters in URLs.
+* "Maximum URL size" sets a limit for how long URLs can be. While Gemini servers are required to enforce a limit of 1024 bytes for URLs, this setting affects all URLs regardless of scheme. Link lines with URLs longer than this will be presented as plain text.
+
 ### 1.1.3 Page caching
 
 When navigating to a new page, the old page is cached in memory. If you navigate back, the cached copy of the page is restored. Think of it as rewinding time — you return to a past time as if nothing had happened. The same applies to forward navigation; cached pages are loaded if available. This allows back and forward navigation to happen instantly, without any network requests.
diff --git a/res/lang/cs.bin b/res/lang/cs.bin
index a45f34ca..a14c5cf4 100644
Binary files a/res/lang/cs.bin and b/res/lang/cs.bin differ
diff --git a/res/lang/de.bin b/res/lang/de.bin
index 9b99e7ed..8dd9d478 100644
Binary files a/res/lang/de.bin and b/res/lang/de.bin differ
diff --git a/res/lang/en.bin b/res/lang/en.bin
index 7b06807d..dd3389ef 100644
Binary files a/res/lang/en.bin and b/res/lang/en.bin differ
diff --git a/res/lang/eo.bin b/res/lang/eo.bin
index 6c3bab91..c65c893c 100644
Binary files a/res/lang/eo.bin and b/res/lang/eo.bin differ
diff --git a/res/lang/es.bin b/res/lang/es.bin
index f82aca48..a0f2a07f 100644
Binary files a/res/lang/es.bin and b/res/lang/es.bin differ
diff --git a/res/lang/es_MX.bin b/res/lang/es_MX.bin
index e1956da3..e83f92e2 100644
Binary files a/res/lang/es_MX.bin and b/res/lang/es_MX.bin differ
diff --git a/res/lang/fi.bin b/res/lang/fi.bin
index fc7ccab8..f390cdca 100644
Binary files a/res/lang/fi.bin and b/res/lang/fi.bin differ
diff --git a/res/lang/fr.bin b/res/lang/fr.bin
index 44b391b4..c268b356 100644
Binary files a/res/lang/fr.bin and b/res/lang/fr.bin differ
diff --git a/res/lang/gl.bin b/res/lang/gl.bin
index 583f7909..04311f53 100644
Binary files a/res/lang/gl.bin and b/res/lang/gl.bin differ
diff --git a/res/lang/hu.bin b/res/lang/hu.bin
index 6776ea40..28ba0e48 100644
Binary files a/res/lang/hu.bin and b/res/lang/hu.bin differ
diff --git a/res/lang/ia.bin b/res/lang/ia.bin
index 2659c595..27e3ba71 100644
Binary files a/res/lang/ia.bin and b/res/lang/ia.bin differ
diff --git a/res/lang/ie.bin b/res/lang/ie.bin
index 33bc6419..244ade42 100644
Binary files a/res/lang/ie.bin and b/res/lang/ie.bin differ
diff --git a/res/lang/isv.bin b/res/lang/isv.bin
index 23726e20..8c177e99 100644
Binary files a/res/lang/isv.bin and b/res/lang/isv.bin differ
diff --git a/res/lang/nl.bin b/res/lang/nl.bin
index 32ec0205..2bdf4a71 100644
Binary files a/res/lang/nl.bin and b/res/lang/nl.bin differ
diff --git a/res/lang/pl.bin b/res/lang/pl.bin
index 52e02876..129d34da 100644
Binary files a/res/lang/pl.bin and b/res/lang/pl.bin differ
diff --git a/res/lang/ru.bin b/res/lang/ru.bin
index 7445fe10..ac407168 100644
Binary files a/res/lang/ru.bin and b/res/lang/ru.bin differ
diff --git a/res/lang/sk.bin b/res/lang/sk.bin
index 76d4dd6f..099f0ccf 100644
Binary files a/res/lang/sk.bin and b/res/lang/sk.bin differ
diff --git a/res/lang/sr.bin b/res/lang/sr.bin
index 11ab7e1d..e550a05a 100644
Binary files a/res/lang/sr.bin and b/res/lang/sr.bin differ
diff --git a/res/lang/tok.bin b/res/lang/tok.bin
index 7e9b02d9..2bf27e86 100644
Binary files a/res/lang/tok.bin and b/res/lang/tok.bin differ
diff --git a/res/lang/tr.bin b/res/lang/tr.bin
index c13d575f..6bd0c26c 100644
Binary files a/res/lang/tr.bin and b/res/lang/tr.bin differ
diff --git a/res/lang/uk.bin b/res/lang/uk.bin
index 609b1c53..520f6c97 100644
Binary files a/res/lang/uk.bin and b/res/lang/uk.bin differ
diff --git a/res/lang/zh_Hans.bin b/res/lang/zh_Hans.bin
index 904fe90d..81ea7de6 100644
Binary files a/res/lang/zh_Hans.bin and b/res/lang/zh_Hans.bin differ
diff --git a/res/lang/zh_Hant.bin b/res/lang/zh_Hant.bin
index 9161c061..029551c7 100644
Binary files a/res/lang/zh_Hant.bin and b/res/lang/zh_Hant.bin differ
diff --git a/src/app.c b/src/app.c
index 0f9249cc..a2ada36e 100644
--- a/src/app.c
+++ b/src/app.c
@@ -244,6 +244,7 @@ static iString *serializePrefs_App_(const iApp *d) {
     appendFormat_String(str, "imageloadscroll arg:%d\n", d->prefs.loadImageInsteadOfScrolling);
     appendFormat_String(str, "cachesize.set arg:%d\n", d->prefs.maxCacheSize);
     appendFormat_String(str, "memorysize.set arg:%d\n", d->prefs.maxMemorySize);
+    appendFormat_String(str, "urlsize.set arg:%d\n", d->prefs.maxUrlSize);
     appendFormat_String(str, "decodeurls arg:%d\n", d->prefs.decodeUserVisibleURLs);
     appendFormat_String(str, "linewidth.set arg:%d\n", d->prefs.lineWidth);
     appendFormat_String(str, "linespacing.set arg:%f\n", d->prefs.lineSpacing);
@@ -1974,6 +1975,8 @@ static iBool handlePrefsCommands_(iWidget *d, const char *cmd) {
                          toInt_String(text_InputWidget(findChild_Widget(d, "prefs.cachesize"))));
         postCommandf_App("memorysize.set arg:%d",
                          toInt_String(text_InputWidget(findChild_Widget(d, "prefs.memorysize"))));
+        postCommandf_App("urlsize.set arg:%d",
+                         toInt_String(text_InputWidget(findChild_Widget(d, "prefs.urlsize"))));
         postCommandf_App("ca.file path:%s",
                          cstrText_InputWidget(findChild_Widget(d, "prefs.ca.file")));
         postCommandf_App("ca.path path:%s",
@@ -2771,6 +2774,13 @@ iBool handleCommand_App(const char *cmd) {
         }
         return iTrue;
     }
+    else if (equal_Command(cmd, "urlsize.set")) {
+        d->prefs.maxUrlSize = arg_Command(cmd);
+        if (d->prefs.maxUrlSize < 1024) {
+            d->prefs.maxUrlSize = 1024; /* Gemini protocol requirement */
+        }
+        return iTrue;
+    }
     else if (equal_Command(cmd, "searchurl")) {
         iString *url = &d->prefs.strings[searchUrl_PrefsString];
         setCStr_String(url, suffixPtr_Command(cmd, "address"));
@@ -3158,6 +3168,8 @@ iBool handleCommand_App(const char *cmd) {
                             collectNewFormat_String("%d", d->prefs.maxCacheSize));
         setText_InputWidget(findChild_Widget(dlg, "prefs.memorysize"),
                             collectNewFormat_String("%d", d->prefs.maxMemorySize));
+        setText_InputWidget(findChild_Widget(dlg, "prefs.urlsize"),
+                            collectNewFormat_String("%d", d->prefs.maxUrlSize));
         setToggle_Widget(findChild_Widget(dlg, "prefs.decodeurls"), d->prefs.decodeUserVisibleURLs);
         setText_InputWidget(findChild_Widget(dlg, "prefs.searchurl"), &d->prefs.strings[searchUrl_PrefsString]);
         setText_InputWidget(findChild_Widget(dlg, "prefs.ca.file"), &d->prefs.strings[caFile_PrefsString]);
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 63d100e2..5cae4138 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -333,13 +333,14 @@ static iRangecc addLink_GmDocument_(iGmDocument *d, iRangecc line, iGmLinkId *li
         link->urlRange = capturedRange_RegExpMatch(&m, 1);
         setRange_String(&link->url, link->urlRange);
         set_String(&link->url, canonicalUrl_String(absoluteUrl_String(&d->url, &link->url)));
-        if (startsWithCase_String(&link->url, "about:command")) {
-            /* This is a special internal page that allows submitting UI events. */
-            if (!d->enableCommandLinks) {
-                delete_GmLink(link);
-                *linkId = 0;
-                return line;
-            }
+        /* If invalid, disregard the link. */
+        if (size_String(&link->url) > prefs_App()->maxUrlSize ||
+            (startsWithCase_String(&link->url, "about:command")
+             /* this is a special internal page that allows submitting UI events */
+             && !d->enableCommandLinks)) {
+            delete_GmLink(link);
+            *linkId = 0;
+            return line;
         }
         /* Check the URL. */ {
             iUrl parts;
@@ -385,7 +386,7 @@ static iRangecc addLink_GmDocument_(iGmDocument *d, iRangecc line, iGmLinkId *li
                 iString *path = newRange_String(parts.path);
                 if (endsWithCase_String(path, ".gif")  || endsWithCase_String(path, ".jpg") ||
                     endsWithCase_String(path, ".jpeg") || endsWithCase_String(path, ".png") ||
-                    endsWithCase_String(path, ".tga")  || endsWithCase_String(path, ".psd") ||                    
+                    endsWithCase_String(path, ".tga")  || endsWithCase_String(path, ".psd") ||
 #if defined (LAGRANGE_ENABLE_WEBP)
                     endsWithCase_String(path, ".webp") ||
 #endif
diff --git a/src/prefs.c b/src/prefs.c
index 13a1dab7..cd86bf60 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -73,6 +73,7 @@ void init_Prefs(iPrefs *d) {
     d->decodeUserVisibleURLs  = iTrue;
     d->maxCacheSize      = 10;
     d->maxMemorySize     = 200;
+    d->maxUrlSize        = 8192;
     setCStr_String(&d->strings[uiFont_PrefsString], "default");
     setCStr_String(&d->strings[headingFont_PrefsString], "default");
     setCStr_String(&d->strings[bodyFont_PrefsString], "default");
diff --git a/src/prefs.h b/src/prefs.h
index ea864f51..25bf56c4 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -172,6 +172,7 @@ struct Impl_Prefs {
     /* Network */
     int              maxCacheSize; /* MB */
     int              maxMemorySize; /* MB */
+    int              maxUrlSize; /* bytes; longer ones will be disregarded */
     /* Style */
     iStringSet *     disabledFontPacks;
     int              gemtextAnsiEscapes;
diff --git a/src/ui/util.c b/src/ui/util.c
index 41f8eaa9..53ee8fda 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -2902,6 +2902,7 @@ iWidget *makePreferences_Widget(void) {
         appendTwoColumnTabPage_Widget(tabs, "${heading.prefs.network}", '6', &headings, &values);
         addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.decodeurls}")));
         addChild_Widget(values, iClob(makeToggle_Widget("prefs.decodeurls")));
+        addPrefsInputWithHeading_(headings, values, "prefs.urlsize", iClob(new_InputWidget(10)));
         /* Cache size. */ {
             iInputWidget *cache = new_InputWidget(4);
             setSelectAllOnFocus_InputWidget(cache, iTrue);
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.11/cdiff/672a534a044d811aa57e927288de50360882ac54
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
85.265762 milliseconds
Gemini-to-HTML Time
0.38096 milliseconds

This content has been proxied by September (3851b).