Kaydet (Commit) 1dcc2440 authored tarafından Guido van Rossum's avatar Guido van Rossum

Reorg TO DO list.

Run rlog commands as pipe so we can cgi.escape(output).
Added self.escape(), like cgi.escape() but also escapes " -- for use
as double-quoted attribute values inside HTML tags.
Fix complains from Mark Lutz: HTTP_HOST is not always set.
üst a0e9a6d3
...@@ -6,19 +6,29 @@ this file as a string constant. ...@@ -6,19 +6,29 @@ this file as a string constant.
XXX TO DO XXX TO DO
XXX User Features TO DO
- next/prev/index links in do_show? - next/prev/index links in do_show?
- customize rcs command pathnames
- explanation of editing somewhere - explanation of editing somewhere
- various embellishments, GIFs, crosslinks, hints, etc. - embellishments, GIFs, crosslinks, hints, etc.
- make references to other Q's and whole sections into links
- support adding annotations, too
XXX Management Features TO DO
- create new sections - create new sections
- rearrange entries - rearrange entries
- delete entries - delete entries
- send email on changes - send email on changes?
- send email on ERRORS!
- optional staging of entries until reviewed? - optional staging of entries until reviewed?
- freeze entries - freeze entries
- username/password for editors - username/password for authors
- Change references to other Q's and whole sections - read section titles from a file (could be a Python file: import faqcustom)
- support adding annotations, too
XXX Code organization TO DO
- customize rcs command pathnames (and everything else)
- make it more generic (so you can create your own FAQ) - make it more generic (so you can create your own FAQ)
- more OO structure, e.g. add a class representing one FAQ entry - more OO structure, e.g. add a class representing one FAQ entry
...@@ -27,7 +37,6 @@ XXX TO DO ...@@ -27,7 +37,6 @@ XXX TO DO
NAMEPAT = "faq??.???.htp" NAMEPAT = "faq??.???.htp"
NAMEREG = "^faq\([0-9][0-9]\)\.\([0-9][0-9][0-9]\)\.htp$" NAMEREG = "^faq\([0-9][0-9]\)\.\([0-9][0-9][0-9]\)\.htp$"
# Like so many other things, this should come from a file.
SECTIONS = { SECTIONS = {
"1": "General information and availability", "1": "General information and availability",
"2": "Python in the real world", "2": "Python in the real world",
...@@ -377,8 +386,11 @@ class FAQServer: ...@@ -377,8 +386,11 @@ class FAQServer:
return return
self.prologue("Info for %s" % name) self.prologue("Info for %s" % name)
print '<PRE>' print '<PRE>'
sys.stdout.flush() p = os.popen("/depot/gnu/plat/bin/rlog -r %s </dev/null 2>&1" %
os.system("/depot/gnu/plat/bin/rlog -r %s </dev/null 2>&1" % self.name) self.name)
output = p.read()
p.close()
print cgi.escape(output)
print '</PRE>' print '</PRE>'
print '<A HREF="faq.py?req=rlog&name=%s">View full rcs log</A>' % name print '<A HREF="faq.py?req=rlog&name=%s">View full rcs log</A>' % name
...@@ -390,8 +402,10 @@ class FAQServer: ...@@ -390,8 +402,10 @@ class FAQServer:
return return
self.prologue("RCS log for %s" % name) self.prologue("RCS log for %s" % name)
print '<PRE>' print '<PRE>'
sys.stdout.flush() p = os.popen("/depot/gnu/plat/bin/rlog %s </dev/null 2>&1" % self.name)
os.system("/depot/gnu/plat/bin/rlog %s </dev/null 2>&1" % self.name) output = p.read()
p.close()
print cgi.escape(output)
print '</PRE>' print '</PRE>'
def checkin(self): def checkin(self):
...@@ -508,8 +522,12 @@ class FAQServer: ...@@ -508,8 +522,12 @@ class FAQServer:
value = "%s;%s" % (author, email) value = "%s;%s" % (author, email)
import urllib import urllib
value = urllib.quote(value) value = urllib.quote(value)
try:
hostname = os.environ['HTTP_HOST']
except KeyError:
hostname = os.environ['SERVER_NAME']
print "Set-Cookie: %s=%s; path=/cgi-bin/;" % (name, value), print "Set-Cookie: %s=%s; path=/cgi-bin/;" % (name, value),
print "domain=%s;" % os.environ['HTTP_HOST'], print "domain=%s;" % hostname,
print "expires=Sat, 01-Jan-2000 00:00:00 GMT" print "expires=Sat, 01-Jan-2000 00:00:00 GMT"
def get_cookie(self): def get_cookie(self):
...@@ -541,7 +559,7 @@ class FAQServer: ...@@ -541,7 +559,7 @@ class FAQServer:
email = email or e email = email or e
print """ print """
Title: <INPUT TYPE=text SIZE=70 NAME=title VALUE="%s"><BR> Title: <INPUT TYPE=text SIZE=70 NAME=title VALUE="%s"><BR>
<TEXTAREA COLS=80 ROWS=20 NAME=text>""" % title <TEXTAREA COLS=80 ROWS=20 NAME=text>""" % self.escape(title)
print cgi.escape(string.strip(text)) print cgi.escape(string.strip(text))
print """</TEXTAREA> print """</TEXTAREA>
<BR> <BR>
...@@ -553,7 +571,19 @@ class FAQServer: ...@@ -553,7 +571,19 @@ class FAQServer:
<BR> <BR>
Log message (reason for the change):<BR> Log message (reason for the change):<BR>
<TEXTAREA COLS=80 ROWS=5 NAME=log>%s\n</TEXTAREA> <TEXTAREA COLS=80 ROWS=5 NAME=log>%s\n</TEXTAREA>
""" % (author, email, self.log) """ % (self.escape(author), self.escape(email), self.escape(self.log))
def escape(self, s):
import regsub
if '&' in s:
s = regsub.gsub("&", "&amp;", s) # Must be done first!
if '<' in s:
s = regsub.gsub("<", "&lt;", s)
if '>' in s:
s = regsub.gsub(">", "&gt;", s)
if '"' in s:
s = regsub.gsub('"', "&quot;", s)
return s
def showheaders(self, headers): def showheaders(self, headers):
print "<UL>" print "<UL>"
...@@ -709,9 +739,9 @@ class FAQServer: ...@@ -709,9 +739,9 @@ class FAQServer:
list.append(cgi.escape(text[i:j])) list.append(cgi.escape(text[i:j]))
i = j i = j
url = prog.group(0) url = prog.group(0)
while url[-1] in ");:,.?": while url[-1] in ");:,.?'\"":
url = url[:-1] url = url[:-1]
url = cgi.escape(url) url = self.escape(url)
if ':' in url: if ':' in url:
repl = '<A HREF="%s">%s</A>' % (url, url) repl = '<A HREF="%s">%s</A>' % (url, url)
else: else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment