Skip to content

Commit

Permalink
Make PBChangeSource more resilient to malformed data.
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Prince <tom.prince@ualberta.net>
  • Loading branch information
tomprince committed May 8, 2011
1 parent bb7b10d commit e70e6f7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions master/buildbot/changes/pb.py
Expand Up @@ -33,6 +33,16 @@ def detached(self, mind):

def perspective_addChange(self, changedict):
log.msg("perspective_addChange called")

if 'revlink' in changedict and not changedict['revlink']:
changedict['revlink'] = ''
if 'repository' in changedict and not changedict['repository']:
changedict['repository'] = ''
if 'project' in changedict and not changedict['project']:
changedict['project'] = ''
if 'files' not in changedict or not changedict['files']:
changedict['files'] = []

files = []
for path in changedict['files']:
if self.prefix:
Expand Down
11 changes: 11 additions & 0 deletions master/buildbot/test/unit/test_changes_pb.py
Expand Up @@ -102,3 +102,14 @@ def check(_):
[ dict(who="bar", files=['a']) ])
d.addCallback(check)
return d

def test_addChange_sanitize_None(self):
cp = pb.ChangePerspective(self.master, None)
d = cp.perspective_addChange(
dict(project=None, revlink=None, repository=None)
)
def check(_):
self.assertEqual(self.added_changes,
[ dict(project="", revlink="", repository="", files=[]) ])
d.addCallback(check)
return d

0 comments on commit e70e6f7

Please sign in to comment.