Closed
Bug 368211
Opened 18 years ago
Closed 18 years ago
Pretty generated directory listings for directories not containing index.html
Categories
(Testing :: General, enhancement)
Testing
General
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: Waldo, Assigned: Waldo)
Details
Attachments
(1 file)
14.63 KB,
patch
|
sayrer
:
review+
|
Details | Diff | Splinter Review |
If I have /path/to/dir/ -> http://localhost:8080/ and /path/to/dir/ doesn't contain an index.html file, it would be nice to see a directory listing. I have mostly-working support done which I'll post probably later today, after I write some minimal tests for it (yes, believe it or not, I did run into an issue or two).
Assignee | ||
Comment 1•18 years ago
|
||
The mentioned issues mostly relate to escaping -- in the initial patch I was outputting the href attributes of links with single-quoting, but encodeURIComponent ignores ' in URLs. It'd escape >/< so you couldn't smuggle valid HTML into the page, but with the right file and with HTML parsing what it is you *might* have been able to get invalid stuff into the page in some manner that would screw up page display. I switched to double-quoting because encodeURIComponent converts " to the urlencoded equivalent.
This is more useful for debugging purposes than for anything else, and even then the only user of the server that uses indexes defines its own index handler, so feel free not to worry *too* much about an in-depth review if you don't want to -- I'm mostly looking for a sanity check and not much more.
Attachment #252937 -
Flags: review?(sayrer)
Comment 2•18 years ago
|
||
Comment on attachment 252937 [details] [diff] [review]
Patch
>Index: netwerk/test/httpserver/httpd.js
>+ var fileList = [];
>+ var files = directory.directoryEntries;
>+ while (files.hasMoreElements())
>+ fileList.push(files.getNext().QueryInterface(Ci.nsIFile));
>+
>+ fileList.sort(fileSort);
>+
>+ for (var i = 0; i < fileList.length; i++)
>+ {
>+ var file = fileList[i];
>+ try
>+ {
>+ if (file.isHidden())
>+ continue;
I would filter hidden files outside the loop, above the sort. Either
fileList = [f for (f in fileList) if (!f.isHidden())]
or
fileList = fileList.filter(function (f) { return !f.isHidden(); });
>Index: netwerk/test/httpserver/test/test_default_index_handler.js
>+/**
>+ * Get child elements of elt with the given name in an ordered list.
>+ */
>+function getChildren(elt, name)
>+{
>+ var rv = [];
>+ var kids = elt.childNodes;
>+ for (var i = 0; i < kids.length; i++)
>+ {
>+ var kid = kids.item(i); // can't use [i] because no classinfo
>+ if (kid.nodeType == 1 && // no Node object either
>+ kid.nodeName == name)
>+ rv.push(kid);
>+ }
>+ return rv;
>+}
Can you use getElementsByTagName instead?
r=sayrer
Attachment #252937 -
Flags: review?(sayrer) → review+
Assignee | ||
Comment 3•18 years ago
|
||
(In reply to comment #2)
> I would filter hidden files outside the loop, above the sort.
I added the filtering in the loop over the directoryEntries enumerator.
> Can you use getElementsByTagName instead?
I'd originally thought no, but on trying again I realized I was QIing to the wrong interface (nsIDOM3Node, not nsIDOMElement). I changed the patch to do this and added the requisite bunch of QI/item calls to make it work.
Patch checked in, with requested changes.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Assignee | ||
Comment 4•17 years ago
|
||
Moving httpd.js bugs to the new Testing :: httpd.js component; filter out this bugmail by searching for "ICanHasHttpd.jsComponent".
Component: Testing → httpd.js
Flags: in-testsuite+
Product: Core → Testing
Target Milestone: mozilla1.9alpha1 → ---
Version: Trunk → unspecified
Assignee | ||
Comment 5•17 years ago
|
||
...and changing the QA contact as well. Filter on the string "BugzillaQAContactHandlingIsStupid".
QA Contact: testing → httpd.js
Assignee | ||
Updated•16 years ago
|
Flags: in-testsuite+
Updated•7 years ago
|
Component: httpd.js → General
You need to log in
before you can comment on or make changes to this bug.
Description
•