Obsolete gnome-mime-data
[oi-userland.git] / components / mail / alpine / patches / longurl.patch
blob2af62dea521839e74019ceb66dd1b9900186db35
1 diff -rc alpine-2.26/pith/conf.c alpine-2.26.longurl/pith/conf.c
2 *** alpine-2.26/pith/conf.c 2022-06-02 18:14:00.491274749 -0600
3 --- alpine-2.26.longurl/pith/conf.c 2022-06-02 18:15:09.259106132 -0600
4 ***************
5 *** 3091,3096 ****
6 --- 3091,3098 ----
7 F_VIEW_SEL_URL, h_config_enable_view_url, PREF_VIEW, 1},
8 {"enable-msg-view-web-hostnames", "Enable Message View Web Hostname Links",
9 F_VIEW_SEL_URL_HOST, h_config_enable_view_web_host, PREF_VIEW, 1},
10 + {"enable-msg-view-long-url", "Enable Recognition of Long URLS without Delimiter",
11 + F_VIEW_LONG_URL, h_config_enable_long_url, PREF_VIEW, 0},
12 {"enable-msg-view-forced-arrows", "Enable Message View Forced Arrows",
13 F_FORCE_ARROWS, h_config_enable_view_arrows, PREF_VIEW, 0},
14 {"external-command-loads-inline-images-only", NULL,
15 diff -rc alpine-2.26/pith/conftype.h alpine-2.26.longurl/pith/conftype.h
16 *** alpine-2.26/pith/conftype.h 2022-06-02 18:14:00.491274749 -0600
17 --- alpine-2.26.longurl/pith/conftype.h 2022-06-02 18:15:09.259106132 -0600
18 ***************
19 *** 465,470 ****
20 --- 465,471 ----
21 F_VIEW_SEL_ATTACH,
22 F_VIEW_SEL_URL,
23 F_VIEW_SEL_URL_HOST,
24 + F_VIEW_LONG_URL,
25 F_SCAN_ADDR,
26 F_FORCE_ARROWS,
27 F_EXTERNAL_INLINE_IMAGES,
28 diff -rc alpine-2.26/pith/mailview.c alpine-2.26.longurl/pith/mailview.c
29 *** alpine-2.26/pith/mailview.c 2022-06-02 18:14:00.491274749 -0600
30 --- alpine-2.26.longurl/pith/mailview.c 2022-06-02 18:15:09.307106014 -0600
31 ***************
32 *** 1843,1860 ****
33 return(0);
37 int
38 url_hilite(long int linenum, char *line, LT_INS_S **ins, void *local)
40 register char *lp, *up = NULL, *urlp = NULL,
41 *weburlp = NULL, *mailurlp = NULL;
42 ! int n, n1, n2, n3, l;
43 char buf[256], color[256];
44 HANDLE_S *h;
45 URL_HILITE_S *uh;
47 ! for(lp = line; ; lp = up + n){
48 /* scan for all of them so we can choose the first */
49 if(F_ON(F_VIEW_SEL_URL,ps_global))
50 urlp = rfc1738_scan(lp, &n1);
51 --- 1843,1920 ----
52 return(0);
55 + int
56 + incomplete_url(char *up, int n, int delim)
57 + {
58 + char *line, *line2;
59 + int rv = 0, len;
61 + if(*(up + n) != '\0')
62 + return 0;
64 + if(delim > 0)
65 + return 1;
67 + if(F_ON(F_VIEW_LONG_URL, ps_global)){
68 + line = up;
69 + if(!strncmp(line, "http://", 7))
70 + line += 7;
71 + else if(!strncmp(line, "https://", 8))
72 + line += 8;
73 + if(strchr(line, '/') != NULL && (line = strrchr(line, '/')) != NULL){
74 + line++;
75 + line2 = strrchr(line, '.');
76 + rv = (strpbrk(line,"+#?=&") != NULL)
77 + || (!line2 || line-line2 > 4);
78 + }
79 + }
80 + return rv;
81 + }
84 int
85 url_hilite(long int linenum, char *line, LT_INS_S **ins, void *local)
87 register char *lp, *up = NULL, *urlp = NULL,
88 *weburlp = NULL, *mailurlp = NULL;
89 ! char *use_this_line, c, *begin_line, *end_line;
90 ! static int scannextline, delim = -1;
91 ! int n, n1, n2, n3, l, len;
92 ! int we_clear = 0, newhandle = 1, tie_off = 0;
93 char buf[256], color[256];
94 HANDLE_S *h;
95 URL_HILITE_S *uh;
97 ! uh = (URL_HILITE_S *) local;
98 ! if(((uh && uh->handlesp && ((h = *(uh->handlesp)) == NULL)) || h->key == 0) ||
99 ! (!line || !*line) || linenum == 0)
100 ! scannextline = 0; /* initialize scannextline */
102 ! if(scannextline != 0){
103 ! up = rfc1738_scan(line, &n1);
105 ! /* if we found a url in the current line, but it is not at the beginning of
106 ! * the next line, or if there is no url in this line, we check if the url
107 ! * in the previous line continues in this line.
108 ! */
110 ! if(line != up){
111 ! if(*uh->handlesp == NULL)
112 ! h = new_handle(uh->handlesp);
113 ! for(h = *uh->handlesp; h->next; h = h->next); /* get last handle */
114 ! len = h->h.url.path ? strlen(h->h.url.path) : 0;
115 ! use_this_line = (char *) fs_get((len + strlen(line) + 1)*sizeof(char));
116 ! sprintf(use_this_line,"%s%s", (h->h.url.path ? h->h.url.path : ""), line);
117 ! we_clear++;
118 ! newhandle = 0;
120 ! else
121 ! use_this_line = line;
123 ! else
124 ! use_this_line = line;
126 ! for(lp = use_this_line; ; lp = up + n){
127 /* scan for all of them so we can choose the first */
128 if(F_ON(F_VIEW_SEL_URL,ps_global))
129 urlp = rfc1738_scan(lp, &n1);
130 ***************
131 *** 1864,1869 ****
132 --- 1924,1933 ----
133 mailurlp = mail_addr_scan(lp, &n3);
135 if(urlp || weburlp || mailurlp){
136 + if(scannextline == 0){
137 + newhandle++;
138 + delim = -1;
140 up = urlp ? urlp :
141 weburlp ? weburlp : mailurlp;
142 if(up == urlp && weburlp && weburlp < up)
143 ***************
144 *** 1871,1878 ****
145 if(mailurlp && mailurlp < up)
146 up = mailurlp;
148 ! if(up == urlp){
149 n = n1;
150 weburlp = mailurlp = NULL;
152 else if(up == weburlp){
153 --- 1935,1956 ----
154 if(mailurlp && mailurlp < up)
155 up = mailurlp;
157 ! if(scannextline != 0 && up == use_this_line){
158 ! scannextline = 0;
159 ! newhandle++;
160 n = n1;
162 + else if(up == urlp){
163 + if(delim < 0)
164 + delim = up > use_this_line && *(up - 1) == '<';
165 + n = n1;
166 + if(incomplete_url(up,n, delim))
167 + scannextline++;
168 + else{
169 + if(scannextline)
170 + tie_off++;
171 + scannextline = 0;
173 weburlp = mailurlp = NULL;
175 else if(up == weburlp){
176 ***************
177 *** 1889,1924 ****
179 uh = (URL_HILITE_S *) local;
181 ! h = new_handle(uh->handlesp);
182 ! h->type = URL;
183 ! h->h.url.path = (char *) fs_get((n + 10) * sizeof(char));
184 ! snprintf(h->h.url.path, n+10, "%s%.*s",
185 weburlp ? "http://" : (mailurlp ? "mailto:" : ""), n, up);
186 ! h->h.url.path[n+10-1] = '\0';
188 if(handle_start_color(color, sizeof(color), &l, uh->hdr_color))
189 ! ins = gf_line_test_new_ins(ins, up, color, l);
190 else if(F_OFF(F_SLCTBL_ITEM_NOBOLD, ps_global))
191 ! ins = gf_line_test_new_ins(ins, up, url_embed(TAG_BOLDON), 2);
193 buf[0] = TAG_EMBED;
194 buf[1] = TAG_HANDLE;
195 snprintf(&buf[3], sizeof(buf)-3, "%d", h->key);
196 buf[sizeof(buf)-1] = '\0';
197 buf[2] = strlen(&buf[3]);
198 ! ins = gf_line_test_new_ins(ins, up, buf, (int) buf[2] + 3);
200 /* in case it was the current selection */
201 ! ins = gf_line_test_new_ins(ins, up + n, url_embed(TAG_INVOFF), 2);
203 if(scroll_handle_end_color(color, sizeof(color), &l, uh->hdr_color))
204 ! ins = gf_line_test_new_ins(ins, up + n, color, l);
205 else
206 ! ins = gf_line_test_new_ins(ins, up + n, url_embed(TAG_BOLDOFF), 2);
208 urlp = weburlp = mailurlp = NULL;
211 return(0);
214 --- 1967,2025 ----
216 uh = (URL_HILITE_S *) local;
218 ! if(tie_off){
219 ! for(;h->next; h = h->next);
220 ! tie_off = 0; /* do only once */
221 ! begin_line = line;
222 ! end_line = line + n - strlen(h->h.url.path);
223 ! fs_give((void **)&(h->h.url.path));
224 ! c = *(use_this_line + n);
225 ! *(use_this_line+n) = '\0';
226 ! h->h.url.path = cpystr(use_this_line);
227 ! *(use_this_line+n) = c;
229 ! else{
230 ! if(newhandle){
231 ! h = new_handle(uh->handlesp);
232 ! h->type = URL;
234 ! begin_line = newhandle ? (we_clear ? line + strlen(line) - strlen(up)
235 ! : up) : line;
236 ! end_line = newhandle ? begin_line + n : line + strlen(line);
237 ! if(scannextline && h->h.url.path)
238 ! fs_give((void **)&(h->h.url.path));
239 ! h->h.url.path = (char *) fs_get((n + 10) * sizeof(char));
240 ! snprintf(h->h.url.path, n+10, "%s%.*s",
241 weburlp ? "http://" : (mailurlp ? "mailto:" : ""), n, up);
242 ! h->h.url.path[n+10-1] = '\0';
245 if(handle_start_color(color, sizeof(color), &l, uh->hdr_color))
246 ! ins = gf_line_test_new_ins(ins, begin_line, color, l);
247 else if(F_OFF(F_SLCTBL_ITEM_NOBOLD, ps_global))
248 ! ins = gf_line_test_new_ins(ins, begin_line, url_embed(TAG_BOLDON), 2);
250 buf[0] = TAG_EMBED;
251 buf[1] = TAG_HANDLE;
252 snprintf(&buf[3], sizeof(buf)-3, "%d", h->key);
253 buf[sizeof(buf)-1] = '\0';
254 buf[2] = strlen(&buf[3]);
255 ! ins = gf_line_test_new_ins(ins, begin_line, buf, (int) buf[2] + 3);
257 /* in case it was the current selection */
258 ! ins = gf_line_test_new_ins(ins, end_line, url_embed(TAG_INVOFF), 2);
260 if(scroll_handle_end_color(color, sizeof(color), &l, uh->hdr_color))
261 ! ins = gf_line_test_new_ins(ins, end_line, color, l);
262 else
263 ! ins = gf_line_test_new_ins(ins, end_line, url_embed(TAG_BOLDOFF), 2);
265 urlp = weburlp = mailurlp = NULL;
268 + if(we_clear)
269 + fs_give((void **)&use_this_line);
271 return(0);
274 diff -rc alpine-2.26/pith/pine.hlp alpine-2.26.longurl/pith/pine.hlp
275 *** alpine-2.26/pith/pine.hlp 2022-06-02 18:14:00.491274749 -0600
276 --- alpine-2.26.longurl/pith/pine.hlp 2022-06-02 18:15:09.327105965 -0600
277 ***************
278 *** 31651,31656 ****
279 --- 31651,31688 ----
280 &lt;End of help on this topic&gt;
281 </BODY>
282 </HTML>
283 + ====== h_config_enable_long_url =====
284 + <HTML>
285 + <HEAD>
286 + <TITLE>FEATURE: <!--#echo var="FEAT_enable-msg-view-long-url"--></TITLE>
287 + </HEAD>
288 + <BODY>
289 + <H1>FEATURE: <!--#echo var="FEAT_enable-msg-view-long-url"--></H1>
291 + This feature modifies the behavior of Alpine's MESSAGE TEXT screen. When this feature
292 + is set alpine will attempt to recognize long urls (those that spread over several
293 + lines in the text) for the HTTP protocol, even when they have not been enclosed between
294 + delimiters &quot;&lt;&quot; and &quot;&gt;&quot;.
296 + <P>The normal behavior in Alpine is that if a URL is preceeded by the &quot;&lt;&quot;
297 + character and this URL was not finished before the end of the line, then a
298 + continuation of the URL is searched in the following line(s). Normally, this type of
299 + URLs will be ended by the &quot;&gt;&quot; character, and if it is not, there is a
300 + possibility of including erroneous text into the URL.
302 + <P>Enabling this feature will make Alpine search for a continuation of certain URLs in
303 + lines following its location. This will be of great help most times, but in some cases
304 + the algorithm will catch some text into the URL that is not part of the URL.
306 + <P>If you find that Alpine failed to recognize correctly a URL simply edit the URL before
307 + passing it to your browser.
309 + <UL>
310 + <LI><A HREF="h_finding_help">Finding more information and requesting help</A>
311 + </UL><P>
312 + &lt;End of help on this topic&gt;
313 + </BODY>
314 + </HTML>
315 ====== h_config_enable_view_addresses =====
316 <HTML>
317 <HEAD>
318 diff -rc alpine-2.26/pith/url.c alpine-2.26.longurl/pith/url.c
319 *** alpine-2.26/pith/url.c 2022-06-02 18:14:00.491274749 -0600
320 --- alpine-2.26.longurl/pith/url.c 2022-06-02 18:15:09.327105965 -0600
321 ***************
322 *** 49,55 ****
323 rfc1738_scan(char *line, int *len)
325 char *colon, *start, *end;
326 ! int n;
328 /* process each : in the line */
329 for(; (colon = strindex(line, ':')) != NULL; line = end){
330 --- 49,55 ----
331 rfc1738_scan(char *line, int *len)
333 char *colon, *start, *end;
334 ! int n, delim;
336 /* process each : in the line */
337 for(; (colon = strindex(line, ':')) != NULL; line = end){
338 ***************
339 *** 139,144 ****
340 --- 139,145 ----
342 if(i != j){
343 *len = end - start;
344 + delim = start > line && *(start - 1) == '<';
347 * Special case handling for comma.
348 ***************
349 *** 148,155 ****
350 * In most cases any way, that's why we have the
351 * exception.
353 ! if(*(end - 1) == ','
354 ! || (*(end - 1) == '.' && (!*end || *end == ' ')))
355 (*len)--;
357 if(*len - (colon - start) > 0)
358 --- 149,156 ----
359 * In most cases any way, that's why we have the
360 * exception.
362 ! if(delim == 0 && (*(end - 1) == ','
363 ! || (*(end - 1) == '.' && (!*end || *end == ' '))))
364 (*len)--;
366 if(*len - (colon - start) > 0)