retitle 502556 fails on sections names that are invalid regular expression,
like Programming/C++
tags 502556 patch pending
thanks
>
>
> > + try:
> > + matcher=re.compile(sect+"/", re.IGNORECASE)
> > + except re.error:
> > + matcher=re.compile(re.escape(sect)+"/", re.IGNORECASE)
>
> Actually there's a minor flaw in your the patch. doc-base sections
> shouldn't be treated as regular expressions at all. Even if there is
> currently no section that both contains regex meta characters, and
> is a valid regex, I can imagine that such a section name might be added
> in the future. Thus re.escape() should be used always, not only in case
> of exception.
In fact I found one yet problem with the Programming/C++ section, namely
URLs generated by browse.cgi are not properly encoded, e.g.
<A HREF="/cgi-bin/doc-central/browse.cgi?section=Programming/C++">C++</A>
instead of
<A HREF="/cgi-bin/doc-central/browse.cgi?section=Programming/C%2B%2B">C++</A>
This makes it impossible to browse that section with doc-central. Since
doc-central seems to be unmaintainedi for a long time, I'm preparing NMU
to fix the problems.
Regards,
Robert
diff -Nur doc-central-1.8.2+nmu1/cgi/contents.cgi doc-central-1.8.2+nmu2/cgi/contents.cgi
--- doc-central-1.8.2+nmu1/cgi/contents.cgi 2008-04-27 14:27:22.000000000 +0200
+++ doc-central-1.8.2+nmu2/cgi/contents.cgi 2008-11-10 18:49:19.000000000 +0100
@@ -12,7 +12,7 @@
hdr=0
if len(sect):
- matcher=re.compile(sect+"/", re.IGNORECASE)
+ matcher=re.compile(re.escape(sect+"/"), re.IGNORECASE)
else:
matcher=re.compile("")
diff -Nur doc-central-1.8.2+nmu1/cgi/docutils.py doc-central-1.8.2+nmu2/cgi/docutils.py
--- doc-central-1.8.2+nmu1/cgi/docutils.py 2008-04-27 14:36:12.000000000 +0200
+++ doc-central-1.8.2+nmu2/cgi/docutils.py 2008-11-10 19:13:04.000000000 +0100
@@ -3,7 +3,7 @@
# throughout Doc-Central.
# Import all system packages we need
-import os, string, sys, cgi, re
+import os, string, sys, cgi, re, urllib
# Import all our own packages
import docinfo, docconfig
@@ -78,12 +78,13 @@
def makesectionlink(sect):
'''Create a URL to the section-index. We assume that the current
script is already the browser'''
+ # Note: the function is never called since it's overriden at the bottom
if os.environ.has_key("SCRIPT_NAME"):
base=os.environ["SCRIPT_NAME"]
else:
base="browse.cgi"
- return base+"?section="+sect
+ return base+"?section="+urllib.quote(sect)
def makedoclink(doc, format=None):
@@ -184,4 +185,4 @@
'''Turn a section-name into an URL to the right section-page using
browse.cgi'''
- return scriptname("browse.cgi") + "?section=%s" % sect
+ return scriptname("browse.cgi") + "?section=%s" % urllib.quote(sect)