summaryrefslogtreecommitdiff
path: root/Mailman/Utils.py
Commit message (Collapse)AuthorAgeFilesLines
...
* canonstr(): New helper function which will take a string from a webbwarsaw2002-09-171-0/+58
| | | | | | | | | | | | | page, which possibly could contain &#XYZ; entities, and convert the string to a Unicode string using the charset of the language provided in the argument list. As a practical kludge, if the charset is us-ascii, we'll use iso-8859-1 instead (which allows a larger number of non-ASCII names in English lists). uncanonstr(): The opposite (sorta) of canonstr(), this takes a Unicode string and returns the encoded string in the charset of the provided language. If a strict conversion fails, then 8-bit characters are converted to their &#XYZ; entities.
* GetDirectories(): Remove. We were only using this to get the list ofbwarsaw2002-09-131-5/+0
| | | | language keys, but we already have that information in LC_DESCRIPTIONS.
* Some Pychecker suggested cleanupsbwarsaw2002-07-171-4/+3
|
* midnight(): New utility function to calculate the epoch seconds of abwarsaw2002-05-281-0/+9
| | | | date in (year, month, day) format.
* QuoteHyperChars() -> websafe()bwarsaw2002-05-221-4/+3
| | | | | Also, use Utils.websafe() consistently throughout, instead of the inconsistent calls to cgi.escape().
* GetRequestURI(): Always cgi.escape() the url retrieved from thebwarsaw2002-05-201-5/+10
| | | | | environment. This closes a cross-site scripting hole in the admin login pages.
* AddressesMatch(), FindMatchingAddresses(): AFAICT, these two functionsbwarsaw2002-05-171-49/+0
| | | | are not used any where.
* Untabificationbwarsaw2002-04-281-5/+5
|
* is_administrivia(): Do the same test on the Subject: field that we dobwarsaw2002-04-051-10/+8
| | | | | on body lines. Also, add `confirm' as an administrivia test. Closes SF bug #454857.
* Patches to help localize where file system layout decisions are made.bwarsaw2002-03-051-6/+5
| | | | | Utils.list_exists(), Utils.list_names(): Don't use LIST_DATA_DIR directly, instead use Site.get_listpath() and Site.get_listnames().
* WHITESPACE -> whitespace everywhere.bwarsaw2002-02-231-8/+72
| | | | | | | | | | | | | | | | | | | ValidateEmail(): Add Dan Mick's suggestion to throw out email addresses with embedded spaces in the (although the calculation of such is done a bit differently). This may not be a complete solution because any address that's first sent through email.Utils.parseaddr() will have embedded spaces collapsed anyway by rfc822.py's similarly named function. That latter is a bug that needs to be fixed in Python, but that's not a high priority right now. Also note that "this is an email address"@dom.ain is (probably) legal and is handled correctly by parseaddr() but will still be rejected by ValidateEmail(). I think that's fine, as anybody who's got embedded spaces in their address is probably going to have a miserable life anyway. to_dollar(), to_percent(), dollar_identifiers(), percent_identifiers(): New functions to support experimental $-string substitutions, and conversions between %-strings and $-strings.
* maketext(): As a final fallback, if a template cannot be found in anybwarsaw2002-01-081-5/+12
| | | | | other search location, use templates/en/* since we know the English template must always exist!
* get_global_password(): Factor this out of check_global_passwordbwarsaw2002-01-061-3/+10
| | | | | because SecurityManager now may want the actual site password, for (optionally) setting a site cookie.
* get_site_email(): Default the `extra' argument to None, and change thebwarsaw2001-11-201-2/+4
| | | | API so that the leading dash on extra shouldn't be included.
* get_domain(): Lower case the host name since host names are case insensitive.bwarsaw2001-11-021-2/+2
|
* List2Dict(): Add `foldcase' argument. When true, coerce all elementsbwarsaw2001-10-151-7/+10
| | | | in the dict to lowercase (yes they must be strings).
* list_exists(): This has to know about config.pck and config.pck.last files.bwarsaw2001-10-041-5/+10
|
* Convert from mimelib to email.bwarsaw2001-10-011-7/+2
| | | | | Also, use cStringIO directly instead of our own hack-around StringIO module.
* ScriptURL(): Instead of using DEFAULT_URL directly, usebwarsaw2001-08-201-2/+2
| | | | | | | | | | DEFAULT_URL_PATTERN and interpolate in the calculated web-request based host name (via get_domain()). This should improve vhost support. get_site_email(): Calculate hostname by looking up get_domain() results in VIRTUAL_HOSTS, defaulting to get_domain() if no vhost information was set.
* _badchars(): Fixed a typo in the last change; the `/' character needsbwarsaw2001-08-141-1/+1
| | | | to be inside the character-set.
* get_site_email(): New function.bwarsaw2001-08-041-0/+6
|
* Some code re-organization.bwarsaw2001-07-191-76/+29
| | | | | | | | | | ValidateEmail(): Add `/' to the list of _badchars in email addresses instead of making it bad only if it points to an existing directory (!). ParseAddrs(): Removed since rfc822.parseaddr() now works for all cases, according to RFC 2822 (but we'll need to supply the rfc822.py from Python 2.2 now).
* unique_message_id(): New function to craft a guaranteed unique Message-ID.bwarsaw2001-07-061-0/+19
|
* maketext(): When interpolating the dict into the template, catchbwarsaw2001-05-311-1/+1
| | | | | ValueError too. This can happen if there's a typo in the template such that a bogus format character appears (e.g. %(blah)y).
* maketext(): Better support for template specialization levels. Thisbwarsaw2001-05-181-37/+83
| | | | | | | | | | | | function now takes an additional optional argument `mlist' which must be a MailList object. It implements an expanding search order for a specific template file: list-centric, domain-centric, site-centric, global default. Each of these prefixes in turn the explicit language passed as an argument, then the list's preferred language, then the site's default language. The first matching template file found is returned. mkdir(): Removed. Use os.mkdir() instead.
* reap(): It's possible under some circumstances to get an ECHILD frombwarsaw2001-05-141-1/+8
| | | | | the os.waitpid() call. This means there are no children left so we can just clear the dictionary and return.
* De-string-module-ification.bwarsaw2001-05-111-31/+33
|
* SetSiteAdminPassword() -> set_global_password(): Also, add optionalbwarsaw2001-05-091-9/+53
| | | | | | | | | | | | | | argument `siteadmin' which if true reads the SITE_PW_FILE (default is true). When false, it reads the LISTCREATOR_PW_FILE. CheckSiteAdminPassword() -> check_global_password(): Same addition of argument. rmdirhier(): Like "rm -r" and unlike os.removedirs(), this recursively deletes everything under a specified directory. get_domain(): Returns the URL hostname/domain as pulled out of HTTP_HOST or SERVER_NAME, and is VIRTUAL_HOST_OVERVIEW aware.
* QuoteHyperChars(): Porting forward from 2.0.4 a patch to get rid ofbwarsaw2001-05-011-15/+2
| | | | | the deprecated regsub so as to quiet a Python 2.1 warning. The standard cgi.escape() function does all this for us.
* chunkify(): Removed.bwarsaw2001-04-091-18/+0
|
* wrap(): Added honor_leading_ws argument, defaulted to 1, which if truebwarsaw2001-04-021-5/+5
| | | | | inhibits wrapping of paragraphs with leading whitespace. When false, all paragraphs are wrapped.
* maketext(): Even though we're using a SafeDict, it's still possiblebwarsaw2001-02-281-4/+7
| | | | | | | | | | | | | for the source string to cause exceptions, e.g. if we try to do '%(hello)f' % {'hello': 'world'} so catch any TypeError and just feed them the raw, uninterpolated template. GetCharSet(): Require a `lang' argument in lieu of using os.environ['LANG'] to pass around this information. Note, this change may cause some temporary breakages.
* MakeDirTree(): Remove (obsoleted by os.makedirs()).bwarsaw2001-02-161-21/+7
| | | | | | maketext(): If the language specific template file doesn't exist, fall back to using $MM/templates. This helps with bootstrapping but may not be the correct long term solution.
* CheckSiteAdminPassword(): Typo that should have chopped off all butbwarsaw2001-02-161-1/+1
| | | | | the trailing newline actually left nothing but the trailing newline! Caught by Ron Jarrell.
* This module still needs lots of cleaning up but for now...bwarsaw2001-02-151-150/+91
| | | | | | | | | | | | | | | | | | | | | | | | De-string-module-ification. Move SafeDict out of this file. Remove the Crypt stuff, using sha instead. SetSiteAdminPassword(), CheckSiteAdminPassword(): Use sha to write the new admin password. Check...() doesn't attempt to compare the challenge against the crypt'd password if the sha comparison fails because the site admin password is much easier to change than all the list passwords. IsAdministrivia() -> is_administrivia(), and mimelib-ify open_ex(): Removed reap(): Additional optional argument `once' which says to just go through the waitpid main loop once. hexlify/unhexlify crud removed (Python 2.0's got them in its binascii module). GetDirectories(), GetLanguageDescr(), GetCharSet(): Added for i18n support.
* maketext(): New optional parameter `lang' which is the language tobwarsaw2000-12-261-2/+4
| | | | | use. Maps to the language-specific subdirectory within the template directory.
* write(): No longer necessary; Python 2.0's extended print syntax isbwarsaw2000-12-071-20/+0
| | | | better.
* ScriptURL(): Hopefully fixes the last place that not havingbwarsaw2000-11-161-1/+5
| | | | | | | DEFAULT_URL end in a slash causes problems. The default value for web_page_url argument is now None, and if it's found to be None in the body of the function, it's set to mm_cfg.DEFAULT_URL (and coerced to always end in a slash).
* SetSiteAdminPassword(), CheckSiteAdminPassword(): These are betterbwarsaw2000-10-021-0/+16
| | | | | suited in Utils than in the SecurityManager class because they don't require the MailList object at all.
* GetPathPieces(): Make this more efficient by using filter(), andbwarsaw2000-09-281-9/+7
| | | | | | | | change the semantics for the most common situation: splitting the $PATH_INFO environment variable into components for the cgi scripts. ScriptURL(): This was the only non-CGI use of GetPathPieces() so now this just uses the filter() call instead of the new semantics.
* maketext(): Default dict argument to None, which means empty list.bwarsaw2000-09-171-1/+3
|
* MakeRandomPassword(): In response to several complaints, and SF bugbwarsaw2000-09-121-8/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | #114136, Jitterbug PR#159, this changes the password generation scheme to use more mnemonically friendly syllables. Passwords are composed of only lower case letters, are lengthened to 6 characters, and should still be meaningfully hard to crack. Examples: doangu siabdo poesza unorbi ziurag okasho ahhuoz idcaih efkoex zubasu nukiis igoffa veehef ogkuoc adebab ovtoci veixep amodbo
* If we're running under Python 2.0, we can grab much fasterbwarsaw2000-08-221-18/+25
| | | | implementations of hexlify and unhexlify from the binascii module.
* Massive cleanup to fix relative/absolute script url calculation inbwarsaw2000-08-011-12/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | response to SF Bug #110753. Specifically, GetNestingLevel(): removed ScriptURL(): New utility function to calculate relative and absolute urls. The basic approach is this: 1. figure out where we are by using REQUEST_URI or SCRIPTNAME+PATH_INFO if that isn't defined in our environment. 2. figure out what the Mailman base url is by taking the `path' component of a urlparse() of the list's web_page_url configvar or DEFAULT_URL if that isn't provided in the arguments. 3. calculate what the relative path is from where we are to baseurl; express this as a string of ../'s 4. tack on the relative url to where we want to go, i.e. the target Elaborations: Optional `absolute' if set always calculates the absolute url as web_page_url/DEFAULT_URL + target. absolute should only be set when generating urls for emails. mm_cfg.CGIEXT is always tacked onto the end, meaning target is supposed to be just the script name and nothing else (anything else should be concatenated onto the return value of this function).
* write(): Oops, de-Python-2.0-ification.bwarsaw2000-07-241-1/+1
|
* write(): Function that acts like print, but let's you specify thebwarsaw2000-07-241-0/+20
| | | | | | output file, whether a trailing newline should be printed, and the separator string. (Sidenote: this is partly to play with some suggestions currently being floated on the python-dev mailing list).
* unhexlify(): Thomas and Dan team up to make this function more thanbwarsaw2000-07-201-2/+2
| | | | twice faster.
* hexlify(), unhexlify(): Make Python 1.5.2 compliant; slightbwarsaw2000-07-201-4/+7
| | | | performance improvements.
* hexlify(), unhexlify(): New helper functions for cookie value encodingbwarsaw2000-07-191-0/+20
| | | | and decoding.
* open_ex(): Transfor OSError into IOError correctly (this is abwarsaw2000-07-051-2/+3
| | | | disgusting hack).