comparison src/c/urweb.c @ 1259:83b1853d1e58

URL-escape with '.' instead of '%', to avoid confusing proxies
author Adam Chlipala <adamc@hcoop.net>
date Tue, 18 May 2010 14:47:56 -0400
parents e80582b927f2
children 236dc296c32d
comparison
equal deleted inserted replaced
1258:78b36c50daf9 1259:83b1853d1e58
1685 if (c == ' ') 1685 if (c == ' ')
1686 *p++ = '+'; 1686 *p++ = '+';
1687 else if (isalnum(c)) 1687 else if (isalnum(c))
1688 *p++ = c; 1688 *p++ = c;
1689 else { 1689 else {
1690 sprintf(p, "%%%02X", c); 1690 sprintf(p, ".%02X", c);
1691 p += 3; 1691 p += 3;
1692 } 1692 }
1693 } 1693 }
1694 1694
1695 *p++ = 0; 1695 *p++ = 0;
1762 if (c == ' ') 1762 if (c == ' ')
1763 uw_writec_unsafe(ctx, '+'); 1763 uw_writec_unsafe(ctx, '+');
1764 else if (isalnum(c)) 1764 else if (isalnum(c))
1765 uw_writec_unsafe(ctx, c); 1765 uw_writec_unsafe(ctx, c);
1766 else { 1766 else {
1767 sprintf(ctx->page.front, "%%%02X", c); 1767 sprintf(ctx->page.front, ".%02X", c);
1768 ctx->page.front += 3; 1768 ctx->page.front += 3;
1769 } 1769 }
1770 } 1770 }
1771 1771
1772 return uw_unit_v; 1772 return uw_unit_v;
1820 int n; 1820 int n;
1821 1821
1822 if (!fromClient) { 1822 if (!fromClient) {
1823 if (*s2 == '_') 1823 if (*s2 == '_')
1824 ++s2; 1824 ++s2;
1825 else if (s2[0] == '%' && s2[1] == '5' && (s2[2] == 'f' || s2[2] == 'F')) 1825 else if ((s2[0] == '%' || s2[0] == '.') && s2[1] == '5' && (s2[2] == 'f' || s2[2] == 'F'))
1826 s2 += 3; 1826 s2 += 3;
1827 } 1827 }
1828 1828
1829 for (s1 = r; *s2; ++s1, ++s2) { 1829 for (s1 = r; *s2; ++s1, ++s2) {
1830 unsigned char c = *s2; 1830 unsigned char c = *s2;
1841 if (sscanf(s2+1, "%02X", &n) != 1) 1841 if (sscanf(s2+1, "%02X", &n) != 1)
1842 uw_error(ctx, FATAL, "Invalid escaped URL byte starting at: %s", s2); 1842 uw_error(ctx, FATAL, "Invalid escaped URL byte starting at: %s", s2);
1843 *s1 = n; 1843 *s1 = n;
1844 s2 += 2; 1844 s2 += 2;
1845 break; 1845 break;
1846 case '.':
1847 if (!fromClient) {
1848 if (s2[1] == 0)
1849 uw_error(ctx, FATAL, "Missing first character of escaped URL byte");
1850 if (s2[2] == 0)
1851 uw_error(ctx, FATAL, "Missing second character of escaped URL byte");
1852 if (sscanf(s2+1, "%02X", &n) != 1)
1853 uw_error(ctx, FATAL, "Invalid escaped URL byte starting at: %s", s2);
1854 *s1 = n;
1855 s2 += 2;
1856 break;
1857 }
1846 default: 1858 default:
1847 *s1 = c; 1859 *s1 = c;
1848 } 1860 }
1849 } 1861 }
1850 *s1++ = 0; 1862 *s1++ = 0;