diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-02-13 20:57:09 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-02-13 20:57:34 +0200 |
commit | 672a534a044d811aa57e927288de50360882ac54 (patch) | |
tree | e605b769a9e40dcdf0b2976dd277ac29beb4c15d /src | |
parent | fb71407409b2debd8e03c42faecd811d168321bf (diff) |
Added a preference for maximum URL size
The setting defaults to 8 KB. Link lines with longer URLs are not recognized as links.
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 12 | ||||
-rw-r--r-- | src/gmdocument.c | 17 | ||||
-rw-r--r-- | src/prefs.c | 1 | ||||
-rw-r--r-- | src/prefs.h | 1 | ||||
-rw-r--r-- | src/ui/util.c | 1 |
5 files changed, 24 insertions, 8 deletions
@@ -244,6 +244,7 @@ static iString *serializePrefs_App_(const iApp *d) { | |||
244 | appendFormat_String(str, "imageloadscroll arg:%d\n", d->prefs.loadImageInsteadOfScrolling); | 244 | appendFormat_String(str, "imageloadscroll arg:%d\n", d->prefs.loadImageInsteadOfScrolling); |
245 | appendFormat_String(str, "cachesize.set arg:%d\n", d->prefs.maxCacheSize); | 245 | appendFormat_String(str, "cachesize.set arg:%d\n", d->prefs.maxCacheSize); |
246 | appendFormat_String(str, "memorysize.set arg:%d\n", d->prefs.maxMemorySize); | 246 | appendFormat_String(str, "memorysize.set arg:%d\n", d->prefs.maxMemorySize); |
247 | appendFormat_String(str, "urlsize.set arg:%d\n", d->prefs.maxUrlSize); | ||
247 | appendFormat_String(str, "decodeurls arg:%d\n", d->prefs.decodeUserVisibleURLs); | 248 | appendFormat_String(str, "decodeurls arg:%d\n", d->prefs.decodeUserVisibleURLs); |
248 | appendFormat_String(str, "linewidth.set arg:%d\n", d->prefs.lineWidth); | 249 | appendFormat_String(str, "linewidth.set arg:%d\n", d->prefs.lineWidth); |
249 | appendFormat_String(str, "linespacing.set arg:%f\n", d->prefs.lineSpacing); | 250 | appendFormat_String(str, "linespacing.set arg:%f\n", d->prefs.lineSpacing); |
@@ -1974,6 +1975,8 @@ static iBool handlePrefsCommands_(iWidget *d, const char *cmd) { | |||
1974 | toInt_String(text_InputWidget(findChild_Widget(d, "prefs.cachesize")))); | 1975 | toInt_String(text_InputWidget(findChild_Widget(d, "prefs.cachesize")))); |
1975 | postCommandf_App("memorysize.set arg:%d", | 1976 | postCommandf_App("memorysize.set arg:%d", |
1976 | toInt_String(text_InputWidget(findChild_Widget(d, "prefs.memorysize")))); | 1977 | toInt_String(text_InputWidget(findChild_Widget(d, "prefs.memorysize")))); |
1978 | postCommandf_App("urlsize.set arg:%d", | ||
1979 | toInt_String(text_InputWidget(findChild_Widget(d, "prefs.urlsize")))); | ||
1977 | postCommandf_App("ca.file path:%s", | 1980 | postCommandf_App("ca.file path:%s", |
1978 | cstrText_InputWidget(findChild_Widget(d, "prefs.ca.file"))); | 1981 | cstrText_InputWidget(findChild_Widget(d, "prefs.ca.file"))); |
1979 | postCommandf_App("ca.path path:%s", | 1982 | postCommandf_App("ca.path path:%s", |
@@ -2771,6 +2774,13 @@ iBool handleCommand_App(const char *cmd) { | |||
2771 | } | 2774 | } |
2772 | return iTrue; | 2775 | return iTrue; |
2773 | } | 2776 | } |
2777 | else if (equal_Command(cmd, "urlsize.set")) { | ||
2778 | d->prefs.maxUrlSize = arg_Command(cmd); | ||
2779 | if (d->prefs.maxUrlSize < 1024) { | ||
2780 | d->prefs.maxUrlSize = 1024; /* Gemini protocol requirement */ | ||
2781 | } | ||
2782 | return iTrue; | ||
2783 | } | ||
2774 | else if (equal_Command(cmd, "searchurl")) { | 2784 | else if (equal_Command(cmd, "searchurl")) { |
2775 | iString *url = &d->prefs.strings[searchUrl_PrefsString]; | 2785 | iString *url = &d->prefs.strings[searchUrl_PrefsString]; |
2776 | setCStr_String(url, suffixPtr_Command(cmd, "address")); | 2786 | setCStr_String(url, suffixPtr_Command(cmd, "address")); |
@@ -3158,6 +3168,8 @@ iBool handleCommand_App(const char *cmd) { | |||
3158 | collectNewFormat_String("%d", d->prefs.maxCacheSize)); | 3168 | collectNewFormat_String("%d", d->prefs.maxCacheSize)); |
3159 | setText_InputWidget(findChild_Widget(dlg, "prefs.memorysize"), | 3169 | setText_InputWidget(findChild_Widget(dlg, "prefs.memorysize"), |
3160 | collectNewFormat_String("%d", d->prefs.maxMemorySize)); | 3170 | collectNewFormat_String("%d", d->prefs.maxMemorySize)); |
3171 | setText_InputWidget(findChild_Widget(dlg, "prefs.urlsize"), | ||
3172 | collectNewFormat_String("%d", d->prefs.maxUrlSize)); | ||
3161 | setToggle_Widget(findChild_Widget(dlg, "prefs.decodeurls"), d->prefs.decodeUserVisibleURLs); | 3173 | setToggle_Widget(findChild_Widget(dlg, "prefs.decodeurls"), d->prefs.decodeUserVisibleURLs); |
3162 | setText_InputWidget(findChild_Widget(dlg, "prefs.searchurl"), &d->prefs.strings[searchUrl_PrefsString]); | 3174 | setText_InputWidget(findChild_Widget(dlg, "prefs.searchurl"), &d->prefs.strings[searchUrl_PrefsString]); |
3163 | setText_InputWidget(findChild_Widget(dlg, "prefs.ca.file"), &d->prefs.strings[caFile_PrefsString]); | 3175 | 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 | |||
333 | link->urlRange = capturedRange_RegExpMatch(&m, 1); | 333 | link->urlRange = capturedRange_RegExpMatch(&m, 1); |
334 | setRange_String(&link->url, link->urlRange); | 334 | setRange_String(&link->url, link->urlRange); |
335 | set_String(&link->url, canonicalUrl_String(absoluteUrl_String(&d->url, &link->url))); | 335 | set_String(&link->url, canonicalUrl_String(absoluteUrl_String(&d->url, &link->url))); |
336 | if (startsWithCase_String(&link->url, "about:command")) { | 336 | /* If invalid, disregard the link. */ |
337 | /* This is a special internal page that allows submitting UI events. */ | 337 | if (size_String(&link->url) > prefs_App()->maxUrlSize || |
338 | if (!d->enableCommandLinks) { | 338 | (startsWithCase_String(&link->url, "about:command") |
339 | delete_GmLink(link); | 339 | /* this is a special internal page that allows submitting UI events */ |
340 | *linkId = 0; | 340 | && !d->enableCommandLinks)) { |
341 | return line; | 341 | delete_GmLink(link); |
342 | } | 342 | *linkId = 0; |
343 | return line; | ||
343 | } | 344 | } |
344 | /* Check the URL. */ { | 345 | /* Check the URL. */ { |
345 | iUrl parts; | 346 | iUrl parts; |
@@ -385,7 +386,7 @@ static iRangecc addLink_GmDocument_(iGmDocument *d, iRangecc line, iGmLinkId *li | |||
385 | iString *path = newRange_String(parts.path); | 386 | iString *path = newRange_String(parts.path); |
386 | if (endsWithCase_String(path, ".gif") || endsWithCase_String(path, ".jpg") || | 387 | if (endsWithCase_String(path, ".gif") || endsWithCase_String(path, ".jpg") || |
387 | endsWithCase_String(path, ".jpeg") || endsWithCase_String(path, ".png") || | 388 | endsWithCase_String(path, ".jpeg") || endsWithCase_String(path, ".png") || |
388 | endsWithCase_String(path, ".tga") || endsWithCase_String(path, ".psd") || | 389 | endsWithCase_String(path, ".tga") || endsWithCase_String(path, ".psd") || |
389 | #if defined (LAGRANGE_ENABLE_WEBP) | 390 | #if defined (LAGRANGE_ENABLE_WEBP) |
390 | endsWithCase_String(path, ".webp") || | 391 | endsWithCase_String(path, ".webp") || |
391 | #endif | 392 | #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) { | |||
73 | d->decodeUserVisibleURLs = iTrue; | 73 | d->decodeUserVisibleURLs = iTrue; |
74 | d->maxCacheSize = 10; | 74 | d->maxCacheSize = 10; |
75 | d->maxMemorySize = 200; | 75 | d->maxMemorySize = 200; |
76 | d->maxUrlSize = 8192; | ||
76 | setCStr_String(&d->strings[uiFont_PrefsString], "default"); | 77 | setCStr_String(&d->strings[uiFont_PrefsString], "default"); |
77 | setCStr_String(&d->strings[headingFont_PrefsString], "default"); | 78 | setCStr_String(&d->strings[headingFont_PrefsString], "default"); |
78 | setCStr_String(&d->strings[bodyFont_PrefsString], "default"); | 79 | 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 { | |||
172 | /* Network */ | 172 | /* Network */ |
173 | int maxCacheSize; /* MB */ | 173 | int maxCacheSize; /* MB */ |
174 | int maxMemorySize; /* MB */ | 174 | int maxMemorySize; /* MB */ |
175 | int maxUrlSize; /* bytes; longer ones will be disregarded */ | ||
175 | /* Style */ | 176 | /* Style */ |
176 | iStringSet * disabledFontPacks; | 177 | iStringSet * disabledFontPacks; |
177 | int gemtextAnsiEscapes; | 178 | 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) { | |||
2902 | appendTwoColumnTabPage_Widget(tabs, "${heading.prefs.network}", '6', &headings, &values); | 2902 | appendTwoColumnTabPage_Widget(tabs, "${heading.prefs.network}", '6', &headings, &values); |
2903 | addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.decodeurls}"))); | 2903 | addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.decodeurls}"))); |
2904 | addChild_Widget(values, iClob(makeToggle_Widget("prefs.decodeurls"))); | 2904 | addChild_Widget(values, iClob(makeToggle_Widget("prefs.decodeurls"))); |
2905 | addPrefsInputWithHeading_(headings, values, "prefs.urlsize", iClob(new_InputWidget(10))); | ||
2905 | /* Cache size. */ { | 2906 | /* Cache size. */ { |
2906 | iInputWidget *cache = new_InputWidget(4); | 2907 | iInputWidget *cache = new_InputWidget(4); |
2907 | setSelectAllOnFocus_InputWidget(cache, iTrue); | 2908 | setSelectAllOnFocus_InputWidget(cache, iTrue); |