dgaudet 99/04/20 14:53:27
Modified: src CHANGES
src/modules/standard mod_autoindex.c
Log:
the width stuff wasn't taking into account &escapes;
PR: 4075
Revision Changes Path
1.1315 +4 -0 apache-1.3/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.1314
retrieving revision 1.1315
diff -u -r1.1314 -r1.1315
--- CHANGES 1999/04/20 19:42:54 1.1314
+++ CHANGES 1999/04/20 21:53:22 1.1315
@@ -1,5 +1,9 @@
Changes with Apache 1.3.7
+ *) When padding the name with spaces for display, mod_autoindex would
+ count &, <, and > in their escaped width, messing up the display.
+ [Dean Gaudet] PR#4075
+
*) PORT: fixed a compilation problem on NEXT.
[Jacques Distler <[EMAIL PROTECTED]>] PR#4130
1.102 +21 -64 apache-1.3/src/modules/standard/mod_autoindex.c
Index: mod_autoindex.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_autoindex.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -r1.101 -r1.102
--- mod_autoindex.c 1999/01/04 19:49:41 1.101
+++ mod_autoindex.c 1999/04/20 21:53:25 1.102
@@ -410,8 +410,8 @@
else {
int width = atoi(&w[10]);
- if (width < 1) {
- return "NameWidth value must be greater than 1";
+ if (width < 5) {
+ return "NameWidth value must be greater than 5";
}
d_cfg->name_width = width;
d_cfg->name_adjust = K_NOADJUST;
@@ -1042,41 +1042,6 @@
}
}
-/*
- * Fit a string into a specified buffer width, marking any
- * truncation. The size argument is the actual buffer size, including
- * the \0 termination byte. The buffer will be prefilled with blanks.
- * If the pad argument is false, any extra spaces at the end of the
- * buffer are omitted. (Used when constructing anchors.)
- */
-static ap_inline char *widthify(const char *s, char *buff, int size, int pad)
-{
- int s_len;
-
- memset(buff, ' ', size);
- buff[size - 1] = '\0';
- s_len = strlen(s);
- if (s_len > (size - 1)) {
- ap_cpystrn(buff, s, size);
- if (size > 1) {
- buff[size - 2] = '>';
- }
- if (size > 2) {
- buff[size - 3] = '.';
- }
- if (size > 3) {
- buff[size - 4] = '.';
- }
- }
- else {
- ap_cpystrn(buff, s, s_len + 1);
- if (pad) {
- buff[s_len] = ' ';
- }
- }
- return buff;
-}
-
static void output_directories(struct ent **ar, int n,
autoindex_config_rec *d, request_rec *r,
int autoindex_opts, char keyid, char direction)
@@ -1088,6 +1053,7 @@
pool *scratch = ap_make_sub_pool(r->pool);
int name_width;
char *name_scratch;
+ char *pad_scratch;
if (name[0] == '\0') {
name = "/";
@@ -1102,10 +1068,10 @@
}
}
}
- ++name_width;
name_scratch = ap_palloc(r->pool, name_width + 1);
- memset(name_scratch, ' ', name_width);
- name_scratch[name_width] = '\0';
+ pad_scratch = ap_palloc(r->pool, name_width + 1);
+ memset(pad_scratch, ' ', name_width);
+ pad_scratch[name_width] = '\0';
if (autoindex_opts & FANCY_INDEXING) {
ap_rputs("<PRE>", r);
@@ -1122,15 +1088,9 @@
);
}
ap_rputs("> ", r);
- }
- emit_link(r, widthify("Name", name_scratch,
- (name_width > 5) ? 5 : name_width, K_NOPAD),
- K_NAME, keyid, direction, static_columns);
- if (name_width > 5) {
- memset(name_scratch, ' ', name_width);
- name_scratch[name_width] = '\0';
- ap_rputs(&name_scratch[5], r);
}
+ emit_link(r, "Name", K_NAME, keyid, direction, static_columns);
+ ap_rputs(pad_scratch + 4, r);
/*
* Emit the guaranteed-at-least-one-space-between-columns byte.
*/
@@ -1156,7 +1116,6 @@
for (x = 0; x < n; x++) {
char *anchor, *t, *t2;
- char *pad;
int nwidth;
ap_clear_pool(scratch);
@@ -1167,15 +1126,12 @@
if (t[0] == '\0') {
t = "/";
}
- /* 1234567890123456 */
t2 = "Parent Directory";
- pad = name_scratch + 16;
anchor = ap_escape_html(scratch, ap_os_escape_path(scratch, t, 0));
}
else {
t = ar[x]->name;
- pad = name_scratch + strlen(t);
- t2 = ap_escape_html(scratch, t);
+ t2 = t;
anchor = ap_escape_html(scratch, ap_os_escape_path(scratch, t, 0));
}
@@ -1200,18 +1156,19 @@
ap_rputs("</A>", r);
}
- ap_rvputs(r, " <A HREF=\"", anchor, "\">",
- widthify(t2, name_scratch, name_width, K_NOPAD),
- "</A>", NULL);
- /*
- * We know that widthify() prefilled the buffer with spaces
- * before doing its thing, so use them.
- */
nwidth = strlen(t2);
- if (nwidth < (name_width - 1)) {
- name_scratch[nwidth] = ' ';
- ap_rputs(&name_scratch[nwidth], r);
+ if (nwidth > name_width) {
+ memcpy(name_scratch, t2, name_width - 3);
+ name_scratch[name_width - 3] = '.';
+ name_scratch[name_width - 2] = '.';
+ name_scratch[name_width - 1] = '>';
+ name_scratch[name_width] = 0;
+ t2 = name_scratch;
+ nwidth = name_width;
}
+ ap_rvputs(r, " <A HREF=\"", anchor, "\">",
+ ap_escape_html(scratch, t2), pad_scratch + nwidth,
+ "</A>", NULL);
/*
* The blank before the storm.. er, before the next field.
*/
@@ -1241,7 +1198,7 @@
}
else {
ap_rvputs(r, "<LI><A HREF=\"", anchor, "\"> ", t2,
- "</A>", pad, NULL);
+ "</A>", pad_scratch + strlen(t2), NULL);
}
ap_rputc('\n', r);
}