@@ -324,6 +324,7 @@ char *i18n_convstring(char *string, char *fromcharset, char *tocharset, size_t *
324
324
origconvbuf [origlen ]= 0x0 ;
325
325
* len = origlen ;
326
326
} else {
327
+ #if 0
327
328
/* hmm... do we really need to do this? (daigo) */
328
329
if (strncasecmp (tocharset ,"ISO-2022-JP" ,11 )== 0 ){
329
330
* len = origlen * 7 - bufleft ;
@@ -334,7 +335,9 @@ char *i18n_convstring(char *string, char *fromcharset, char *tocharset, size_t *
334
335
}else {
335
336
* len = origlen * 7 - bufleft ;
336
337
}
337
-
338
+ #else
339
+ * len = origlen * 7 - bufleft ;
340
+ #endif
338
341
* (origconvbuf + * len )= 0x0 ;
339
342
}
340
343
@@ -1488,6 +1491,7 @@ char *parseemail(char *input, /* string to parse */
1488
1491
char tempbuff [MAXLINE ];
1489
1492
char * ptr ;
1490
1493
char * lastpos = input ;
1494
+ char * start = NULL ;
1491
1495
struct Push buff ;
1492
1496
1493
1497
char * at ;
@@ -1500,32 +1504,51 @@ char *parseemail(char *input, /* string to parse */
1500
1504
else
1501
1505
at = "@" ;
1502
1506
1507
+ if (strchr (input , '@' ) == NULL && strstr (input , "@" ) == NULL ) {
1508
+ /* nothing to do here */
1509
+ return strsav (input );
1510
+ }
1511
+
1503
1512
INIT_PUSH (buff );
1504
1513
1505
1514
while (* input ) {
1506
- if ((ptr = strchr (input , '@' )))
1507
- at_len = 1 ;
1508
- else if ((ptr = strstr (input , "@" )))
1509
- at_len = 5 ;
1515
+
1516
+ /* skip detection if this is an escape or non-ascii sequence */
1517
+ if (set_iso2022jp ) {
1518
+ iso2022_state (input , & in_ascii , & esclen );
1519
+ if (esclen != 0 ) {
1520
+ input += esclen ;
1521
+ continue ;
1522
+ }
1523
+ if (in_ascii == FALSE) {
1524
+ input ++ ;
1525
+ start = NULL ;
1526
+ continue ;
1527
+ }
1528
+ }
1529
+
1530
+ if (start == NULL ) {
1531
+ start = input ;
1532
+ }
1533
+
1534
+ ptr = NULL ;
1535
+ if (* input == '@' ) {
1536
+ ptr = input ;
1537
+ at_len = 1 ;
1538
+ } else if (strncmp (input , "@" , 5 ) == 0 ) {
1539
+ ptr = input ;
1540
+ at_len = 5 ;
1541
+ }
1542
+
1510
1543
if (ptr ) {
1511
1544
/* found a @ */
1512
1545
char * email = ptr - 1 ;
1513
1546
char content [2 ];
1514
- int backoff = ptr - input ; /* max */
1547
+ int backoff = ptr - start ; /* max */
1515
1548
1516
1549
#define VALID_IN_EMAIL_USERNAME "a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~"
1517
1550
#define VALID_IN_EMAIL_DOMAINNAME "a-zA-Z0-9.-"
1518
1551
1519
- if (set_iso2022jp ) {
1520
- for (; ptr > input ; input ++ ) {
1521
- iso2022_state (input , & in_ascii , & esclen );
1522
- if (!esclen ) continue ;
1523
- input += esclen ;
1524
- if (in_ascii == TRUE)
1525
- backoff = ptr - input ;
1526
- }
1527
- }
1528
-
1529
1552
/* check left side */
1530
1553
while (backoff ) {
1531
1554
int res ;
@@ -1572,23 +1595,26 @@ char *parseemail(char *input, /* string to parse */
1572
1595
PushString (& buff , tempbuff );
1573
1596
1574
1597
input = ptr + strlen (mailbuff ) + at_len ;
1598
+ start = input ;
1575
1599
lastpos = input ;
1576
1600
continue ;
1577
1601
}
1578
1602
else { /* bad address */
1579
1603
PushString (& buff , mailaddr );
1580
1604
input = ptr + strlen (mailbuff ) + at_len ;
1605
+ start = input ;
1581
1606
lastpos = input ;
1582
1607
continue ;
1583
1608
}
1584
1609
}
1585
1610
}
1586
1611
/* no address, continue from here */
1587
- input = ptr + 1 ;
1612
+ input = ptr + at_len ;
1613
+ start = input ;
1588
1614
continue ;
1589
1615
}
1590
1616
else
1591
- input = strchr ( input , '\0' ) ;
1617
+ input ++ ;
1592
1618
}
1593
1619
if (lastpos < input ) {
1594
1620
PushNString (& buff , lastpos , input - lastpos );
0 commit comments