comparison src/c/urweb.c @ 1087:e81434513720

Proper JavaScript-side URI escaping/de-escaping; fix C-side URL encoding of big characters
author Adam Chlipala <adamc@hcoop.net>
date Thu, 24 Dec 2009 10:44:53 -0500
parents 8e240c007442
children f1647f16097d
comparison
equal deleted inserted replaced
1086:99aebdf30257 1087:e81434513720
1588 r = p = ctx->heap.front; 1588 r = p = ctx->heap.front;
1589 if (s[0] == '_') 1589 if (s[0] == '_')
1590 *p++ = '_'; 1590 *p++ = '_';
1591 1591
1592 for (; *s; s++) { 1592 for (; *s; s++) {
1593 char c = *s; 1593 unsigned char c = *s;
1594 1594
1595 if (c == ' ') 1595 if (c == ' ')
1596 *p++ = '+'; 1596 *p++ = '+';
1597 else if (isalnum(c)) 1597 else if (isalnum(c))
1598 *p++ = c; 1598 *p++ = c;
1665 1665
1666 if (s[0] == '_') 1666 if (s[0] == '_')
1667 uw_writec_unsafe(ctx, '_'); 1667 uw_writec_unsafe(ctx, '_');
1668 1668
1669 for (; *s; s++) { 1669 for (; *s; s++) {
1670 char c = *s; 1670 unsigned char c = *s;
1671 1671
1672 if (c == ' ') 1672 if (c == ' ')
1673 uw_writec_unsafe(ctx, '+'); 1673 uw_writec_unsafe(ctx, '+');
1674 else if (isalnum(c)) 1674 else if (isalnum(c))
1675 uw_writec_unsafe(ctx, c); 1675 uw_writec_unsafe(ctx, c);
1735 else if (s2[0] == '%' && s2[1] == '5' && (s2[2] == 'f' || s2[2] == 'F')) 1735 else if (s2[0] == '%' && s2[1] == '5' && (s2[2] == 'f' || s2[2] == 'F'))
1736 s2 += 3; 1736 s2 += 3;
1737 } 1737 }
1738 1738
1739 for (s1 = r; *s2; ++s1, ++s2) { 1739 for (s1 = r; *s2; ++s1, ++s2) {
1740 char c = *s2; 1740 unsigned char c = *s2;
1741 1741
1742 switch (c) { 1742 switch (c) {
1743 case '+': 1743 case '+':
1744 *s1 = ' '; 1744 *s1 = ' ';
1745 break; 1745 break;