ignore mal-formed input lines
sort usernames by default
This commit is contained in:
parent
6295daf7f7
commit
53d561e65d
1 changed files with 6 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue