You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-cvs@httpd.apache.org by jo...@apache.org on 2003/04/22 05:50:26 UTC
cvs commit: httpd-apreq-2/src apreq.c apreq_tables.c
joes 2003/04/21 20:50:25
Modified: src apreq.c apreq_tables.c
Log:
Port IKEBE Tomohiro's %uXXXX patch to apreq-2.
Revision Changes Path
1.14 +65 -10 httpd-apreq-2/src/apreq.c
Index: apreq.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/src/apreq.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- apreq.c 21 Apr 2003 04:29:46 -0000 1.13
+++ apreq.c 22 Apr 2003 03:50:25 -0000 1.14
@@ -255,7 +255,7 @@
register char digit;
#if !APR_CHARSET_EBCDIC
- digit = ((what[0] >= 'A') ? ((what[0] & 0xdf) - 'A') + 10 : (what[0] - '0'));
+ digit = (what[0] >= 'A' ? ((what[0] & 0xdf) - 'A') + 10 : (what[0] - '0'));
digit *= 16;
digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A') + 10 : (what[1] - '0'));
#else /*APR_CHARSET_EBCDIC*/
@@ -270,6 +270,32 @@
return (digit);
}
+static APR_INLINE unsigned int x2ui(const char *what) {
+ register unsigned int digit = 0;
+
+#if !APR_CHARSET_EBCDIC
+ digit = (what[0] >= 'A' ? ((what[0] & 0xdf) - 'A') + 10 : (what[0] - '0'));
+ digit *= 16;
+ digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A') + 10 : (what[1] - '0'));
+ digit *= 16;
+ digit += (what[2] >= 'A' ? ((what[2] & 0xdf) - 'A') + 10 : (what[2] - '0'));
+ digit *= 16;
+ digit += (what[3] >= 'A' ? ((what[1] & 0xdf) - 'A') + 10 : (what[3] - '0'));
+
+#else /*APR_CHARSET_EBCDIC*/
+ char xstr[7];
+ xstr[0]='0';
+ xstr[1]='x';
+ xstr[2]=what[0];
+ xstr[3]=what[1];
+ xstr[4]=what[2];
+ xstr[5]=what[3];
+ xstr[6]='\0';
+ digit = apr_xlate_conv_byte(ap_hdrs_from_ascii, 0xFFFF & strtol(xstr, NULL, 16));
+#endif /*APR_CHARSET_EBCDIC*/
+ return (digit);
+}
+
APREQ_DECLARE(apr_ssize_t) apreq_decode(char *d, const char *s,
const apr_size_t slen)
{
@@ -302,16 +328,45 @@
*d = x2c(s + 1);
s += 2;
}
- else if (s[1] == 'u' && apr_isxdigit(s[2]) &&
- apr_isxdigit(s[3]) && apr_isxdigit(s[4]) &&
- apr_isxdigit(s[5]))
+ else if ((s[1] == 'u' || s[1] == 'U') &&
+ apr_isxdigit(s[2]) && apr_isxdigit(s[3]) &&
+ apr_isxdigit(s[4]) && apr_isxdigit(s[5]))
{
- /* XXX: Need to decode oddball
- * javascript unicode escapes: %uXXXX
- * For now we'll just give up.
- */
- badesc = 1;
- *d = '%';
+ unsigned int c = x2ui(s+2);
+ if (c < 0x80) {
+ *d = c;
+ }
+ else if (c < 0x800) {
+ *d++ = 0xc0 | (c >> 6);
+ *d = 0x80 | (c & 0x3f);
+ }
+ else if (c < 0x10000) {
+ *d++ = 0xe0 | (c >> 12);
+ *d++ = 0x80 | ((c >> 6) & 0x3f);
+ *d = 0x80 | (c & 0x3f);
+ }
+ else if (c < 0x200000) {
+ *d++ = 0xf0 | (c >> 18);
+ *d++ = 0x80 | ((c >> 12) & 0x3f);
+ *d++ = 0x80 | ((c >> 6) & 0x3f);
+ *d = 0x80 | (c & 0x3f);
+ }
+ else if (c < 0x4000000) {
+ *d++ = 0xf8 | (c >> 24);
+ *d++ = 0x80 | ((c >> 18) & 0x3f);
+ *d++ = 0x80 | ((c >> 12) & 0x3f);
+ *d++ = 0x80 | ((c >> 6) & 0x3f);
+ *d = 0x80 | (c & 0x3f);
+ }
+ else if (c < 0x8000000) {
+ *d++ = 0xfe | (c >> 30);
+ *d++ = 0x80 | ((c >> 24) & 0x3f);
+ *d++ = 0x80 | ((c >> 18) & 0x3f);
+ *d++ = 0x80 | ((c >> 12) & 0x3f);
+ *d++ = 0x80 | ((c >> 6) & 0x3f);
+ *d = 0x80 | (c & 0x3f);
+ }
+ s += 4;
}
else {
badesc = 1;
1.19 +11 -1 httpd-apreq-2/src/apreq_tables.c
Index: apreq_tables.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/src/apreq_tables.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- apreq_tables.c 21 Apr 2003 16:09:09 -0000 1.18
+++ apreq_tables.c 22 Apr 2003 03:50:25 -0000 1.19
@@ -148,7 +148,17 @@
/* MUST ensure n's parent exists (>=0) before using LR(n) */
#define LR(n) ( ( (n)[o].tree[PARENT][o].tree[LEFT] == (n) ) ? LEFT : RIGHT )
-#define PROMOTE(o,r,p) do rotate(o,r,o[p].tree[PARENT],!LR(p)); while (o[p].tree[PARENT] >= 0)
+#define PROMOTE(o,r,p) do rotate(o,r,o[p].tree[PARENT],!LR(p)); \
+ while (o[p].tree[PARENT] >= 0)
+
+/**
+ * pivot child
+ * / \ / \
+ * child direction == rotate ===> 1 pivot
+ * / \ / \
+ * 1 2 2 direction
+ *
+ */
static APR_INLINE void rotate(apreq_table_entry_t *o,
int *root,