Merge branch 'release/0.5.2'

* release/0.5.2:
  Bump version to 0.5.2
  Strip non hexadecimal characters from GPG fingerprint input
  Fix issues with incompletely filled forms
This commit is contained in:
Jan Dittberner 2017-09-12 22:15:44 +02:00
commit b1a9f39c33
4 changed files with 31 additions and 21 deletions

View file

@ -28,6 +28,7 @@ from wtforms import IntegerField, StringField, RadioField
from wtforms.validators import ( from wtforms.validators import (
AnyOf, DataRequired, Email, Length, Optional, Regexp AnyOf, DataRequired, Email, Length, Optional, Regexp
) )
from string import hexdigits
class FingerPrint(Regexp): class FingerPrint(Regexp):
@ -40,16 +41,24 @@ class PlainText(Regexp):
super(PlainText, self).__init__(r'^[a-zA-Z\-0-9]*$') super(PlainText, self).__init__(r'^[a-zA-Z\-0-9]*$')
def gpg_fingerprint(data):
if data is not None:
return "".join([
char for char in str(data) if char.lower() in hexdigits])
return data
class DeveloperData(FlaskForm): class DeveloperData(FlaskForm):
email = StringField('email', validators=[DataRequired(), Email()]) email = StringField('email', validators=[DataRequired(), Email()])
name = StringField('name', validators=[DataRequired()]) name = StringField('name', validators=[Optional(), DataRequired()])
gpgfp = StringField('gpgfp', validators=[ gpgfp = StringField('gpgfp', filters=[gpg_fingerprint], validators=[
FingerPrint(), Optional(), FingerPrint(), Length(min=32, max=40)
Length(min=32, max=40) ])
username = StringField('username', validators=[Optional(), PlainText()])
nonddemail = StringField('nonddemail', validators=[Optional(), Email()])
aliothusername = StringField('aliothusername', validators=[
Optional(), PlainText()
]) ])
username = StringField('username', validators=[PlainText()])
nonddemail = StringField('nonddemail', validators=[Email()])
aliothusername = StringField('aliothusername', validators=[PlainText()])
mode = RadioField( mode = RadioField(
'mode', default='html', choices=[ 'mode', default='html', choices=[
('json', _('JSON')), ('html', _('HTML')) ('json', _('JSON')), ('html', _('HTML'))

View file

@ -3,7 +3,7 @@
# #
# Debian Member Portfolio Service url builder # Debian Member Portfolio Service url builder
# #
# Copyright © 2009-2015 Jan Dittberner <jan@dittberner.info> # Copyright © 2009-2017 Jan Dittberner <jan@dittberner.info>
# #
# This file is part of the Debian Member Portfolio Service. # This file is part of the Debian Member Portfolio Service.
# #
@ -73,7 +73,7 @@ def _build_quoted_fields(fields):
qfields[key] = quote_plus(value) qfields[key] = quote_plus(value)
else: else:
qfields[key] = value qfields[key] = value
qfields[key] = qfields[key].replace('%', '%%') qfields[key] = str(qfields[key]).replace('%', '%%')
if 'gpgfp' not in qfields: if 'gpgfp' not in qfields:
fpr = keyfinder.getFingerprintByEmail(fields['email'].encode('utf8')) fpr = keyfinder.getFingerprintByEmail(fields['email'].encode('utf8'))

View file

@ -3,7 +3,7 @@
# #
# Debian Member Portfolio Service views # Debian Member Portfolio Service views
# #
# Copyright © 2015 Jan Dittberner <jan@dittberner.info> # Copyright © 2015-2017 Jan Dittberner <jan@dittberner.info>
# #
# This file is part of the Debian Member Portfolio Service. # This file is part of the Debian Member Portfolio Service.
# #
@ -162,25 +162,26 @@ def urllist():
form = DeveloperData(request.values) form = DeveloperData(request.values)
if form.validate(): if form.validate():
fields = dddatabuilder.build_data(form.data['email']) fields = dddatabuilder.build_data(form.data['email'])
rp = request.values
form_data = form.data.copy()
if fields['type'] in (dddatabuilder.TYPE_DD, dddatabuilder.TYPE_DM): if fields['type'] in (dddatabuilder.TYPE_DD, dddatabuilder.TYPE_DM):
for dmtuple in DM_TUPLES: for dmtuple in DM_TUPLES:
if not dmtuple[0] in rp or not rp[dmtuple[0]]: if not form_data[dmtuple[0]]:
rp[dmtuple[0]] = fields[dmtuple[1]] form_data[dmtuple[0]] = fields[dmtuple[1]]
if fields['type'] == dddatabuilder.TYPE_DD: if fields['type'] == dddatabuilder.TYPE_DD:
for ddtuple in DD_TUPLES: for ddtuple in DD_TUPLES:
if not ddtuple[0] in rp or not rp[ddtuple[0]]: if not form_data[ddtuple[0]]:
rp[ddtuple[0]] = fields[ddtuple[1]] form_data[ddtuple[0]] = fields[ddtuple[1]]
if form.data['wikihomepage'] is None: if not form_data['wikihomepage']:
log.debug('generate wikihomepage from name') log.debug('generate wikihomepage from name')
form.data['wikihomepage'] = "".join([ form_data['wikihomepage'] = "".join([
part.capitalize() for part in form.data['name'].split() part.capitalize() for part in form_data['name'].split()
]) ])
data = build_urls(form.data) data = build_urls(form_data)
if form.data['mode'] == 'json': if form_data['mode'] == 'json':
response = make_response(json.dumps(dict( response = make_response(json.dumps(dict(
[("{}.{}".format(entry[1], entry[2].name), entry[3]) [("{}.{}".format(entry[1], entry[2].name), entry[3])
for entry in data if entry[0] == 'url']))) for entry in data if entry[0] == 'url'])))

View file

@ -29,7 +29,7 @@ except ImportError:
setup( setup(
name='debianmemberportfolio', name='debianmemberportfolio',
version='0.5.1', version='0.5.2',
description='service to create Debian Member Portfolio URLs', description='service to create Debian Member Portfolio URLs',
long_description="""This is a service implementation that returns a set of long_description="""This is a service implementation that returns a set of
personalized URLs as outlined in https://wiki.debian.org/DDPortfolio. It personalized URLs as outlined in https://wiki.debian.org/DDPortfolio. It