libdb: make parse_filename smarter