Changeset 1802 for trunk/dll/newview.c
- Timestamp:
- Apr 5, 2015, 10:40:17 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/newview.c
r1790 r1802 44 44 containing an email. Fixed the mailto code to avoid a buffer over run (trap) 45 45 and to cut trailing punctuation marks from the address 46 04 Apr 15 GKY Have https:// recognized as a url. Strip trailing punctuation from urls. 46 47 47 48 ***********************************************************************/ … … 200 201 static FATTRS Fattrs; 201 202 202 // mailstr checks for a designated character in a string then cuts the string203 //to the first word that contains the character then prepends <mailto: and appends >204 205 203 BOOL isemailaddress(PSZ pszLine) 206 204 { 207 205 CHAR *tmp; 208 CHAR *p, *pp ;206 CHAR *p, *pp, *q; 209 207 210 208 tmp = xmallocz(strlen(pszLine) + 1, pszSrcFile, __LINE__); … … 213 211 memcpy(tmp, pszLine, strlen(pszLine)); 214 212 tmp[strlen(pszLine) + 1] = 0; 213 chop_at_crnl(tmp); 215 214 bstripcr(tmp); 216 215 p = tmp; 217 216 p++; 218 p = strchr(p, '@');217 q = p = strchr(p, '@'); 219 218 if (!p) { 220 219 free(tmp); … … 231 230 continue; 232 231 else if (*p == '{') { 233 if ( !strchr(p ,'}') || pp - p > 4) {232 if (q != p - 1 || !strchr(p ,'}')) { 234 233 free(tmp); 235 234 return FALSE; 236 235 } 236 else // probable IP address literal user will need to decide if it is valid 237 break; 237 238 } 238 239 else { … … 245 246 return TRUE; 246 247 } 247 248 // mailstr checks for a designated character in a string then cuts the string 249 //to the first word that contains the character then prepends <mailto: and appends > 248 250 PSZ mailstr(CHAR *pszSrc, CHAR *pszFindChar, LONG StrLens) 249 251 { … … 317 319 p = urld->line; 318 320 do { 319 p = strnstr(p, "http://", e - p);321 p = strnstr(p, "http://", e - p) ? strnstr(p, "http://", e - p) : strnstr(p, "https://", e - p); 320 322 if (p) { 321 323 strncpy(urld->url, p, min(e - p, SEARCHSTRINGLEN - 1)); 322 324 urld->url[min(e - p, SEARCHSTRINGLEN - 1)] = 0; 323 325 pp = urld->url; 324 while (*pp && *pp != ' ' && *pp != '\r' && *pp != '\n' && 326 while (*pp && *pp != ' ' && *pp != '\r' && *pp != '\n' && *pp != '\t' && 325 327 *pp != '\"') 326 328 pp++; 327 *pp = 0; 329 *pp = 0; 330 strip_trail_char(",.;:'>", urld->url); 328 331 WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_INSERTITEM, 329 332 MPFROM2SHORT(LIT_END, 0), MPFROMP(urld->url)); 330 333 p++; 331 334 } 332 335 } … … 339 342 urld->url[min(e - p, SEARCHSTRINGLEN - 1)] = 0; 340 343 pp = urld->url; 341 while (*pp && *pp != ' ' && *pp != '\r' && *pp != '\n' && 344 while (*pp && *pp != ' ' && *pp != '\r' && *pp != '\n' && *pp != '\t' && 342 345 *pp != '\"') 343 346 pp++; 344 *pp = 0; 347 *pp = 0; 348 strip_trail_char(",.;:'>", urld->url); 345 349 WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_INSERTITEM, 346 350 MPFROM2SHORT(LIT_END, 0), MPFROMP(urld->url)); 347 351 p++; 348 352 } … … 352 356 if (isemailaddress(p)) { 353 357 memcpy(szUrlString, urld->line, SEARCHSTRINGLEN - 1); 354 mailstr(szUrlString, "@", e - p); 355 memcpy(urld->url, szUrlString, strlen( szUrlString) + 1); 358 mailstr(szUrlString, "@", e - p); 359 p = strrchr(szUrlString, '.'); 360 memcpy(urld->url, szUrlString, (p + 4) - &szUrlString);//strlen( szUrlString) + 1); 356 361 urld->url[strlen(szUrlString) + 1] = 0; 357 362 if (pp = strchr(urld->url, '>')) 358 363 *pp = 0; 359 364 WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_INSERTITEM, 360 365 MPFROM2SHORT(LIT_END, 0), MPFROMP(urld->url)); 361 366 } 362 367 *urld->url = 0; … … 413 418 MPFROMP(urld->url)); 414 419 if (*urld->url) { 415 if (!strncmp(urld->url, "http://", 7) ) {420 if (!strncmp(urld->url, "http://", 7) || !strncmp(urld->url, "https://", 8)) { 416 421 WinDismissDlg(hwnd, 1); 417 422 break; … … 884 889 && (!ad->markedlines 885 890 || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND))) 886 && strnstr(ad->lines[whichline], "http://", 887 e - ad->lines[whichline])) {891 && (strnstr(ad->lines[whichline], "http://", e - ad->lines[whichline]) || 892 strnstr(ad->lines[whichline], "https://", e - ad->lines[whichline]))) { 888 893 GpiSetColor(hps, standardcolors[ad->colors[COLORS_HTTPFORE]]); 889 894 GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_HTTPBACK]]); … … 949 954 && (!ad->markedlines 950 955 || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND))) 951 && strnstr(ad->lines[whichline], "http://",e - ad->lines[whichline])) { 956 && (strnstr(ad->lines[whichline], "http://",e - ad->lines[whichline]) || 957 strnstr(ad->lines[whichline], "https://",e - ad->lines[whichline]))) { 952 958 GpiSetColor(hps, standardcolors[ad->colors[COLORS_HTTPFORE]]); 953 959 GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_HTTPBACK]]); … … 1441 1447 ad->ftpin = TRUE; 1442 1448 if ((*httprun || fHttpRunWPSDefault) && !ad->ignorehttp && 1443 strstr(ad->text, "http://"))1449 (strstr(ad->text, "http://") || strstr(ad->text, "https://"))) 1444 1450 ad->httpin = TRUE; 1445 1451 if (*mailrun && !ad->ignoremail && isemailaddress(ad->text)) … … 2499 2505 2500 2506 if ((ad->httpin && (*httprun || fHttpRunWPSDefault) && 2501 strnstr(ad->lines[whichline], "http://", width)) || 2507 (strnstr(ad->lines[whichline], "http://", width) || 2508 strnstr(ad->lines[whichline], "https://", width))) || 2502 2509 (ad->ftpin && (*ftprun || fFtpRunWPSDefault) && 2503 2510 strnstr(ad->lines[whichline], "ftp://", width)) || … … 3420 3427 ad->httpin = FALSE; 3421 3428 if (ad->text && (*httprun || fHttpRunWPSDefault) && !ad->ignorehttp && 3422 strstr(ad->text, "http://"))3429 (strstr(ad->text, "http://") || strstr(ad->text, "https://"))) 3423 3430 ad->httpin = TRUE; 3424 3431 IgnoreHTTP = ad->ignorehttp;
Note:
See TracChangeset
for help on using the changeset viewer.