Example #1
0
    def htmlEncode(s):
        """HTML encode special characters.
        Alias for `WebUtils.Funcs.htmlEncode`, quotes the special characters
        &, <, >, and \"

        """
        return Funcs.htmlEncode(s)
Example #2
0
 def writeStyleSheet(self):
     """
     Writes stylesheet (CSS) information -- you should probably
     override styleSheetHref() or styleSheet() instead.
     """
     href = self.styleSheetHref()
     if href:
         self.write('<link rel="stylesheet" href="%s" type="text/css">\n' %
                    Funcs.htmlEncode(href))
     styles = self.styleSheet()
     if styles:
         self.write('<style type="text/css"><!--\n%s\n--></style>\n' %
                    styles)
Example #3
0
 def writeBody(self):
     """
     Writes the <body> portion of the page by writing the
     <body>...</body> (making use of self.htBodyArgs()) and invoking
     self.writeBodyParts() in between.
     """
     wr = self.writeln
     bodyArgs = self.htBodyArgs()
     if type(bodyArgs) is DictionaryType:
         bodyArgs = ' '.join(
             map(lambda x: '%s="%s"' % (x[0], Funcs.htmlEncode(x[1])),
                 bodyArgs.items()))
     if bodyArgs:
         wr('<body %s>' % bodyArgs)
     else:
         wr('<body>')
     self.writeBodyContent()
     wr('</body>')
Example #4
0
	def writeContent(self):
		self.write("""
		<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>Upload Test</title>
  </head>

  <body>
    <h1>Upload Test</h1>
	<p>%s
	<p>

<form action="FileUpload.py" method=POST enctype="multipart/form-data">
<input type="FILE" name="filename">
<p>
<input type="SUBMIT" name="_action_" value="fileupload">
</form>
  </body>
</html>

		""" % (Funcs.htmlEncode(self.__doc__)))
Example #5
0
 def htmlEncode(s):
     """HTML encode special characters.
     Alias for ``WebUtils.Funcs.htmlEncode``, quotes the special characters
     &, <, >, and \"
     """
     return Funcs.htmlEncode(s)
Example #6
0
	def fileupload(self, trans):

		f = self.request().field('filename')

		contents = f.file.read()

		self.write("""<html><head></head><body bgcolor='#DDDDEE'>
		Here's the file you submitted:
		<hr>
		name:%s<p>
		type:%s<p>
		type_options:%s<p>
		disposition:%s<p>
		disposition_options:%s<p>
		headers:%s<p>
		size: %s<p>
		contents:<hr>%s </body>
		""" % (f.filename, f.type, f.type_options, f.disposition, f.disposition_options, f.headers, len(contents), Funcs.htmlEncode(contents) ) )
Example #7
0
 def testHtmlRoundTrip(self):
     t = '<test>\n\t"1 < 2 & 2 > 1"\n</test>'
     self.assertEqual(Funcs.htmlDecode(Funcs.htmlEncode(t)), t)
Example #8
0
 def htmlEncode(self, s):
     return Funcs.htmlEncode(s)
Example #9
0
 def writeTitle(self):
     self.write('<title>%s</title>\n' % Funcs.htmlEncode(self.title()))
Example #10
0
 def testHtmlRoundTrip(self):
     t = '<test>\n\t"1 < 2 & 2 > 1"\n</test>'
     self.assertEqual(Funcs.htmlDecode(Funcs.htmlEncode(t)), t)