Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
48123b26
Commit
48123b26
authored
Oct 17, 2002
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Security fixes: reject non-wiki-word page names; set homedir to /tmp.
Show errors returned by store(). A few nits.
parent
f606e8d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
Demo/cgi/cgi3.py
Demo/cgi/cgi3.py
+13
-6
No files found.
Demo/cgi/cgi3.py
View file @
48123b26
...
...
@@ -11,8 +11,8 @@ def main():
form
=
cgi
.
FieldStorage
()
print
"Content-type: text/html"
print
cmd
=
form
.
getvalue
(
"cmd"
)
or
"view"
page
=
form
.
getvalue
(
"page"
)
or
"FrontPage"
cmd
=
form
.
getvalue
(
"cmd"
,
"view"
)
page
=
form
.
getvalue
(
"page"
,
"FrontPage"
)
wiki
=
WikiPage
(
page
)
wiki
.
load
()
method
=
getattr
(
wiki
,
'cmd_'
+
cmd
,
None
)
or
wiki
.
cmd_view
...
...
@@ -20,10 +20,12 @@ def main():
class
WikiPage
:
homedir
=
os
.
path
.
dirname
(
sys
.
argv
[
0
])
homedir
=
"/tmp"
scripturl
=
os
.
path
.
basename
(
sys
.
argv
[
0
])
def
__init__
(
self
,
name
):
if
not
self
.
iswikiword
(
name
):
raise
ValueError
,
"page name is not a wiki word"
self
.
name
=
name
self
.
load
()
...
...
@@ -48,7 +50,7 @@ class WikiPage:
words[i] = word
print "".join(words)
print "<hr>"
print "<p>", self.mklink("edit", self.name, "Edit this page") + "
,
"
print "<p>", self.mklink("edit", self.name, "Edit this page") + "
;
"
print self.mklink("view", "FrontPage", "go to front page") + "."
def cmd_edit(self, form, label="Change"):
...
...
@@ -64,8 +66,13 @@ class WikiPage:
def cmd_create(self, form):
self.data = form.getvalue("text", "").strip()
self.store()
self.cmd_view(form)
error = self.store()
if error:
print "<h1>I'
m
sorry
.
That
didn
't work</h1>"
print "<p>An error occurred while attempting to write the file:"
print "<p>", escape(error)
else:
self.cmd_view(form)
def cmd_new(self, form):
self.cmd_edit(form, label="Create Page")
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment