validator: fix ASCII password check to verify if it can be *encoded* in ascii
In Python 2, unicode strings have a .decode method (which really doesn't make sense). Python 3 has more strict typing by design, and unicode strings don't have a .decode method.
A Unicode string "is ASCII" if it can be encoded as ASCII. The check should thus *encode* to ASCII - not decode.
gist: make it a bit more clear how gist_access_id is used ... and how it is different from gist_id
A gist has a gist_access_id which gives access to it. For private Gists, it is a multi-letter secure random string.
gist_id is the primary key in the database and thus an automatically incrementing integer. It is also used as the not-so-secret gist_access_id for public gists.
This gets rid of one odd safe_unicode applied to an int.
lib: handle both HTML, unsafe strings, and exceptions passed to helpers.flash()
Before, h.flash would trust any input to contain html ... and callers would convert exceptions to string, often with a simple str() or unicode() ... which really didn't deserve to be trusted.
Instead, only trust messages that have a __html__ and escape anything else ... but also apply str/unicode on the parameter so the caller doesn't have to but *can* pass an exception directly.
lib: let get_git_version invoke git as all other commands do, without special options
There is no need for _bare or _safe. It is fine to have '-c core.quotepath=false' before '--version', and it is perfectly fine to get a RepositoryError if things go terribly wrong.
lib: establish py3 compatible strategy for string handling: introducing safe_bytes and deprecating safe_str
The meaning of safe_str will change when moving to py3. All use of safe_str is thus tech debt that we have to chop off, mostly by moving to either safe_unicode or safe_bytes ... or dropping because we know what we are doing and rely on the improved type safety in py3.
We will soon move to Python 3 which only will support 5.1 or later.
Remove old hacks and tech debt.
Also avoids future warning: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
lib: only maintain one copy of safe_str / safe_unicode
The standalone-ish nature of vcs gets a bit in the way. It already depends on some very generic Kallithea functionality. But for now, avoid code duplication, and let Kallithea use vcs functionality instead of duplicating it.
feeds: replace webhelpers.feedgenerator with simple mako templating for rendering RSS/Atom XML
Most of the complexity in RSS libraries is in dynamically supporting all kinds of attributes. For our use, we have a small static set of attributes we use, and it is simpler to just use mako.
Also, webhelpers is dead, and the alternatives seem quite heavy.
repo: don't just report user name and email in one field - separate things properly
In the repo RSS feed, report author as <author>name@example.com (User Name)</author> instead of using <dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">User Name <name@example.com></dc:creator>
And in the ATOM feed with name and email separate: <author> <name>User Name</name> <email>name@example.com</email> </author> Instead of <name>User Name <name@example.com></name>
journal: don't include email in author name - avoid double data
In journal RSS feed, report author as: <author>name@example.com (User Name)</author> instead of double email due to: <author>name@example.com (User Name <name@example.com>)</author>
In the journal ATOM feed, report author as: <author> <name>user Name</name> <email>test_admin@example.com</email> </author> instead of using double email due to: <name>name@example.com (User Name <name@example.com>)</name>
app: drop finally handling in BaseVCSController.__call__
Our optional 'wrapper' middleware is logging response times more correctly after b42ee1bdf082 - there is no point in logging the timing of the __call__ in the main app.
Similarly, the session was removed too early. But TurboGears is already picking up our db session and using DBSessionRemoverMiddleware to .remove() it ... and at the right time. So just stop trying.
utils: drop make_ui parameter clear_session - this utility function should never mess with sessions
clear_session seems to have been based on the idea that utility functions that happened to create a session also should clean up. But instead, we now consistently take care of session removal at a high level.
app: let app instance creation remove its SA Session when done
The app instance is usually created early or on demand before serving the first request, and the app instance might sit idle for a while before receiving the first request. The app creation will touch the database, and we have to consider the lifetime of the database session it is using. The cbf524e4c1a3 commit message gives some reasons we should remove the session when done.
But instead of handle it inside utility functions, we would rather handle sessions at a high level as here.
The caching condition has been False since ffd45b185016 . That makes sense - caching as implemented would leak the repo list of other users without considering permissions. The repo list is however only loaded on demand, and caching is not that important.
routing: fix files_annotate_home annotate value to be compatible with Routes >= 2
The routing entry for files_annotate_home had annotate=True. That primarily served to let the controller files.index differentiate files_annotate_home from files_home and files_home_nopath . Anything true can work.
test_files.py is creating files_annotate_home URLs in an odd way: Instead of explicitly specifying it is a files_annotate_home URL, it passes expected controller parameters and expects routing to find a URL that would provide these parameters. It thus also has to specify the otherwise "invisible" annotate value. For Routes < 2, True works just fine. For Routes >= 2, it seems to expect values that actually can be encoded in URLs.
routing: drop default f_path for changelog_file_home
There is no point in creating a changelog_file_home URL without specifying f_path. The default value of None is thus never any good. And especially, it is unclear what a value of None really means.
When attempting to use ed25519 SSH keys, parse_pub_key() failed with: SshKeyParseError: Incorrect SSH key - base64 part is not 'ssh-ed25519' as claimed but 'ssh-ed25519'
The problem was the hardcoding of the string length of the key type -- 7 or '\x07' -- which fits ssh-rsa and ssh-dss but not ssh-ed25519.
scripts/make-release: install ldap and pam to fix isort instabilities
isort (triggered by scripts/whitespacecleanup.sh) needs to know which modules are local and which are not, to separate them with a newline. If a module cannot be found, it will be treated as local, apparently.
When ldap is not installed in the current environment, a difference was created by isort in kallithea/bin/ldap_sync.py.