diff options
author | 2006-02-07 07:49:02 +0000 | |
---|---|---|
committer | 2006-02-07 07:49:02 +0000 | |
commit | 0555597c28fd4610b7464fb9a7ccee750913c94d (patch) | |
tree | 4c6e49ed918506ed7f93fd3553b6805b7023f7fb /www-apps/pyblosxom-plugins/files | |
parent | Fixed digest to modified package (diff) | |
download | overlay-0555597c28fd4610b7464fb9a7ccee750913c94d.tar.gz overlay-0555597c28fd4610b7464fb9a7ccee750913c94d.tar.bz2 overlay-0555597c28fd4610b7464fb9a7ccee750913c94d.zip |
Upgraded contact plugin. Renamed ebuild 1.3
svn path=/stable/; revision=653
Diffstat (limited to 'www-apps/pyblosxom-plugins/files')
-rw-r--r-- | www-apps/pyblosxom-plugins/files/contact.py | 176 | ||||
-rw-r--r-- | www-apps/pyblosxom-plugins/files/digest-pyblosxom-plugins-1.3 (renamed from www-apps/pyblosxom-plugins/files/digest-pyblosxom-plugins-1.2.1) | 0 |
2 files changed, 38 insertions, 138 deletions
diff --git a/www-apps/pyblosxom-plugins/files/contact.py b/www-apps/pyblosxom-plugins/files/contact.py index d3fcf38..993fe5c 100644 --- a/www-apps/pyblosxom-plugins/files/contact.py +++ b/www-apps/pyblosxom-plugins/files/contact.py @@ -31,7 +31,7 @@ __license__ = "GPL 2+" # Python imports -import urlparse + # Pyblosxom imports from Pyblosxom.renderers.blosxom import Renderer @@ -46,143 +46,39 @@ MESSAGE_KEY = "contact_error_message" _form_fields = ['name', 'email', 'subject', 'message'] _default_template = """ +<style type="text/css"> +<!-- +#contactForm label { + float: left; + width: 25%; + padding-top: 3px; + margin-bottom: 5px; + } +#contactForm input, textarea { + width: 70%; + margin-right: 10px; + margin-bottom: 5px; + } +--> +</style> <div> -<h2>Contact me</h2> +<h3>Contact me</h3> <div style="display:block;">$contact_error_message</div> <form name="contactForm" id="contactForm" method="post" action="$base_url$contact_urltrigger"> -<div class="contactLine"> - <div class="contactLabel"> - <label class="contactLine" for="name" title="Your name">Name</label> - </div> - <input type="text" name="name" id="name" value="$contact_name" /><br /> -</div> -<div class="contactLine"> - <div class="contactLabel"> - <label class="contactLine" for="email" title="Your email address">Email</label> - </div> - <input type="text" name="email" id="email" value="$contact_email" /><br /> -</div> -<div class="contactLine"> - <div class="contactLabel"> - <label class="contactLine" for="subject" title="Subject of your message">Subject</label> - </div> - <input class="contactLine" type="text" name="subject" id="subject" value="$contact_subject" /><br /> -</div> -<div class="contactText"> - <div class="contactLabel"> - <label class="contactText" for="message" title="Your message">Message</label> - </div> - <textarea name="message" id="message" style="height:150px;">$contact_message</textarea><br /> -</div> -<div class="contactSubmit"> - <div class="contactButton"> - <input class="contactSubmit" type="submit" value="Send" style="width:auto; margin-right:0;" /> - </div> - <div class="contactButton"> - <input class="contactSubmit" type="reset" value="Reset" style="width:auto; margin-right:0;" /> - </div> -</div> +<label for="name" title="Your name">Name</label> +<input type="text" name="name" id="name" value="$contact_name" /><br /> +<label for="email" title="Your email address">Email</label> +<input type="text" name="email" id="email" value="$contact_email" /><br /> +<label for="subject" title="Subject of your message">Subject</label> +<input type="text" name="subject" id="subject" value="$contact_subject" /><br /> +<label for="message" title="Your message">Message</label> +<textarea name="message" id="message" style="height:150px;">$contact_message</textarea><br /> +<input type="submit" value="Send" style="width:auto; margin-right:0;" /> +<input type="reset" value="Reset" style="width:auto; margin-right:0;" /> </form> </div> """ -################################################################################ -## -## Helper functions -## -################################################################################ - -rfc822_specials = '()<>@,;:\\"[]' - -def isAddressValid(addr): - ''' - Taken from - - http://www.secureprogramming.com/?action=view&feature=recipes&recipeid=1 - - Posted by Matt Messier on Tue, Sep 02, 2003 (06:19 PM) GMT - - >>> isAddressValid('djfhdfh') - 0 - >>> isAddressValid('djfhdfh@test.com') - 8 - >>> isAddressValid('dj@fhdfh@test.com') - 0 - >>> isAddressValid('dj\@fhdfh@test.com') - 0 - >>> isAddressValid('dj"@"fhdfh@test.com') - 0 - >>> isAddressValid('dj" "fhdfh@test.com') - 0 - >>> isAddressValid('dj\" \"fhdfh@test.com') - 0 - >>> isAddressValid('dj." ".fhdfh@test.com') - 13 - >>> isAddressValid('dj."@ ".fhdfh@test.com') - 14 - >>> isAddressValid('dj."@<> ".fhdfh@test.com') - 16 - >>> isAddressValid('dj."@<>ü ".fhdfh@test.com') - 0 - >>> isAddressValid('dj<>fhdfh@test.com') - 0 - >>> isAddressValid('dj\<\>fhdfh@test.com') - 0 - >>> isAddressValid('dj\ fhdfh@test.com') - 0 - >>> isAddressValid('dj\\ fhdfh@test.com') - 0 - >>> isAddressValid('djfhdfh@test.com.de') - 8 - >>> isAddressValid('djfhdfh@test.co<m.de') - 0 - ''' - # Ported from Recipe 3.9 in Secure Programming Cookbook for C and C++ by - # John Viega and Matt Messier (O'Reilly 2003) - - # First we validate the name portion (name@domain) - c = 0 - while c < len(addr): - if addr[c] == '"' and (not c or addr[c - 1] == '.' or addr[c - 1] == '"'): - c = c + 1 - while c < len(addr): - if addr[c] == '"': - c = c + 1 - break - if addr[c] == '\\' and addr[c + 1] == ' ': - c = c + 2 - continue - if ord(addr[c]) < 32 or ord(addr[c]) >= 127: return 0 - c = c + 1 - else: return 0 - if addr[c] == '@': break - if addr[c] != '.': return 0 - c = c + 1 - continue - if addr[c] == '@': break - if ord(addr[c]) <= 32 or ord(addr[c]) >= 127: return 0 - if addr[c] in rfc822_specials: return 0 - c = c + 1 - if not c or addr[c - 1] == '.': return 0 - - # Next we validate the domain portion (name@domain) - domain = c = c + 1 - if domain >= len(addr): return 0 - count = 0 - while c < len(addr): - if addr[c] == '.': - if c == domain or addr[c - 1] == '.': return 0 - count = count + 1 - if ord(addr[c]) <= 32 or ord(addr[c]) >= 127: return 0 - if addr[c] in rfc822_specials: return 0 - c = c + 1 - - ## The final return statement was modified to return the split point - ## (position of @) so that the email can split in its two subsections. - if count >= 1: - return domain - - def verify_installation(request): config = request.getConfiguration() retval = 1 @@ -206,16 +102,24 @@ class ContactRenderer(Renderer): def render(self, header=1): config = self._request.getConfiguration() data = self._request.getData() + http = self._request.getHttp() - # root_datadir is normaly set after the cb_pathinfo callback. + # path_info and root_datadir are normaly set after the cb_pathinfo callback. # but if a plugin implements cb_handle (as this one does), # cb_pathinfo is never called. # if root_datadir is not set and flavourdir is not set in config.py # an exception is thrown in BlosxomRenderer._getFlavour. # so set root_datadir here explicitly to prevent that. + if not 'path_info' in data: + if http.get('PATH_INFO', ''): + path_info = http['PATH_INFO'].split('/') + path_info = [x for x in path_info if x != ''] + data['path_info'] = list(path_info) + if not 'root_datadir' in data: data['root_datadir'] = config['datadir'] + # initialize flavour self.flavour = self._getFlavour(data.get('flavour', 'html')) data['content-type'] = self.flavour['content_type'].strip() @@ -263,7 +167,7 @@ def _handle_post(request): error_messages = [] if not 'HTTP_REFERER' in http or \ - not http['HTTP_REFERER'].startswith('://'.join(urlparse.urlsplit(config['base_url'])[0:1])): + not http['HTTP_REFERER'].startswith(config['base_url']): data[MESSAGE_KEY] = "Posting from foreign hosts not allowed.<br />\nUse the form below to send your message." return @@ -277,10 +181,6 @@ def _handle_post(request): parser.feed(form[field].value) email[field] = parser.gettext() - if 'email' in email.keys() and not isAddressValid(email['email']): - error = True - error_messages.append("Invalid email address '%s'. Cannot deliver your message!" % email['email']) - if error: data[MESSAGE_KEY] = "<br />\n".join(error_messages) _remember_email(email, data) @@ -380,7 +280,6 @@ def cb_handle(args): def cb_end(args): - # cleanup request = args['request'] data = request.getData() if INIT_KEY in data: @@ -388,3 +287,4 @@ def cb_end(args): if MESSAGE_KEY in data: del data[MESSAGE_KEY] + diff --git a/www-apps/pyblosxom-plugins/files/digest-pyblosxom-plugins-1.2.1 b/www-apps/pyblosxom-plugins/files/digest-pyblosxom-plugins-1.3 index e69de29..e69de29 100644 --- a/www-apps/pyblosxom-plugins/files/digest-pyblosxom-plugins-1.2.1 +++ b/www-apps/pyblosxom-plugins/files/digest-pyblosxom-plugins-1.3 |