equal
deleted
inserted
replaced
33 urlerr = util.urlerr |
33 urlerr = util.urlerr |
34 urlreq = util.urlreq |
34 urlreq = util.urlreq |
35 |
35 |
36 |
36 |
37 def escape(s, quote=None): |
37 def escape(s, quote=None): |
38 '''Replace special characters "&", "<" and ">" to HTML-safe sequences. |
38 """Replace special characters "&", "<" and ">" to HTML-safe sequences. |
39 If the optional flag quote is true, the quotation mark character (") |
39 If the optional flag quote is true, the quotation mark character (") |
40 is also translated. |
40 is also translated. |
41 |
41 |
42 This is the same as cgi.escape in Python, but always operates on |
42 This is the same as cgi.escape in Python, but always operates on |
43 bytes, whereas cgi.escape in Python 3 only works on unicodes. |
43 bytes, whereas cgi.escape in Python 3 only works on unicodes. |
44 ''' |
44 """ |
45 s = s.replace(b"&", b"&") |
45 s = s.replace(b"&", b"&") |
46 s = s.replace(b"<", b"<") |
46 s = s.replace(b"<", b"<") |
47 s = s.replace(b">", b">") |
47 s = s.replace(b">", b">") |
48 if quote: |
48 if quote: |
49 s = s.replace(b'"', b""") |
49 s = s.replace(b'"', b""") |
584 loggingfh=None, |
584 loggingfh=None, |
585 loggingname=b's', |
585 loggingname=b's', |
586 loggingopts=None, |
586 loggingopts=None, |
587 sendaccept=True, |
587 sendaccept=True, |
588 ): |
588 ): |
589 ''' |
589 """ |
590 construct an opener suitable for urllib2 |
590 construct an opener suitable for urllib2 |
591 authinfo will be added to the password manager |
591 authinfo will be added to the password manager |
592 |
592 |
593 The opener can be configured to log socket events if the various |
593 The opener can be configured to log socket events if the various |
594 ``logging*`` arguments are specified. |
594 ``logging*`` arguments are specified. |
598 ``loggingopts`` is a dict of keyword arguments to pass to the constructed |
598 ``loggingopts`` is a dict of keyword arguments to pass to the constructed |
599 ``util.socketobserver`` instance. |
599 ``util.socketobserver`` instance. |
600 |
600 |
601 ``sendaccept`` allows controlling whether the ``Accept`` request header |
601 ``sendaccept`` allows controlling whether the ``Accept`` request header |
602 is sent. The header is sent by default. |
602 is sent. The header is sent by default. |
603 ''' |
603 """ |
604 timeout = ui.configwith(float, b'http', b'timeout') |
604 timeout = ui.configwith(float, b'http', b'timeout') |
605 handlers = [] |
605 handlers = [] |
606 |
606 |
607 if loggingfh: |
607 if loggingfh: |
608 handlers.append( |
608 handlers.append( |