~ubuntu-branches/ubuntu/jaunty/ubuntu-system-service/jaunty

« back to all changes in this revision

Viewing changes to UbuntuSystemService/utils.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2008-08-19 14:18:18 UTC
  • Revision ID: james.westby@ubuntu.com-20080819141818-6gs3fa82dxidv52p
Tags: 0.1.6
* debian/control:
  - add missing depends on policykit and python-dbus
* add socks support
* support no_proxy environment

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import re
 
2
 
 
3
def verify_proxy(proxy_type, proxy):
 
4
    """
 
5
    This verifies a proxy string. It works by whitelisting
 
6
    certain charackters: 0-9a-zA-Z:/?=-;~+
 
7
    """
 
8
    # protocol://host:port/stuff
 
9
    verify_str = "%s://[a-zA-Z0-9.-]+:[0-9]+/*$" % proxy_type
 
10
 
 
11
    if not re.match(verify_str, proxy):
 
12
            return False
 
13
    return True
 
14
 
 
15
def verify_no_proxy(proxy):
 
16
    """
 
17
    This verifies a proxy string. It works by whitelisting
 
18
    certain charackters: 0-9a-zA-Z:/?=-;~+
 
19
    """
 
20
    # protocol://host:port/stuff
 
21
    verify_str = "[a-zA-Z0-9.-:,]+" 
 
22
 
 
23
    if not re.match(verify_str, proxy):
 
24
            return False
 
25
    return True