From 53d561e65ddd1c223176be369f50cc3db7761b1f Mon Sep 17 00:00:00 2001 From: lars Date: Sat, 5 Jun 2010 01:22:20 +0000 Subject: [PATCH] ignore mal-formed input lines sort usernames by default --- htman/htpasswd.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htman/htpasswd.py b/htman/htpasswd.py index f485217..6c1611c 100644 --- a/htman/htpasswd.py +++ b/htman/htpasswd.py @@ -55,8 +55,9 @@ class HtpasswdFile: """ self.entries = {} for line in open(self.filename, 'r').readlines(): - username, pwhash = line.split(':', 1) - self.entries[username] = pwhash + if ":" in line: + username, pwhash = line.split(':', 1) + self.entries[username] = pwhash def save(self): """Write the htpasswd file to disk @@ -96,5 +97,7 @@ class HtpasswdFile: self.entries.pop(username) def get_usernames(self): - return self.entries.keys() + names = self.entries.keys() + names.sort() + return names