text
stringlengths 0
828
|
---|
req.content_type = 'text/html' |
if req.method != 'HEAD': |
req.write("""""" |
<html> |
<head> |
<title>Intermediate page for URLs clicked on MS Office Documents</title> |
<meta http-equiv=""REFRESH"" content=""5;url=%(url)s""></meta> |
</head> |
<body> |
<p>You are going to be redirected to the desired content within 5 seconds. If the redirection does not happen automatically please click on <a href=""%(url)s"">%(url_ok)s</a>.</p> |
</body> |
</html>"""""" % { |
'url': escape(req.unparsed_uri, True), |
'url_ok': escape(req.unparsed_uri) |
}) |
raise apache.SERVER_RETURN(apache.DONE) |
req.headers_out[""Location""] = url |
if req.response_sent_p: |
raise IOError(""Cannot redirect after headers have already been sent."") |
req.status = redirection_type |
req.write('<p>Please go to <a href=""%s"">here</a></p>\n' % url) |
raise apache.SERVER_RETURN(apache.DONE)" |
4734,"def rewrite_to_secure_url(url, secure_base=None): |
"""""" |
Rewrite URL to a Secure URL |
@param url URL to be rewritten to a secure URL. |
@param secure_base: Base URL of secure site (defaults to CFG_SITE_SECURE_URL). |
"""""" |
if secure_base is None: |
secure_base = cfg.get('CFG_SITE_SECURE_URL') |
url_parts = list(urlparse(url)) |
url_secure_parts = urlparse(secure_base) |
url_parts[0] = url_secure_parts[0] |
url_parts[1] = url_secure_parts[1] |
return urlunparse(url_parts)" |
4735,"def get_referer(req, replace_ampersands=False): |
"""""" Return the referring page of a request. |
Referer (wikipedia): Referer is a common misspelling of the word |
""referrer""; so common, in fact, that it made it into the official |
specification of HTTP. When visiting a webpage, the referer or |
referring page is the URL of the previous webpage from which a link was |
followed. |
@param req: request |
@param replace_ampersands: if 1, replace & by & in url |
(correct HTML cannot contain & characters alone) |
"""""" |
try: |
referer = req.headers_in['Referer'] |
if replace_ampersands == 1: |
return referer.replace('&', '&') |
return referer |
except KeyError: |
return ''" |
4736,"def make_canonical_urlargd(urlargd, default_urlargd): |
"""""" Build up the query part of an URL from the arguments passed in |
the 'urlargd' dictionary. 'default_urlargd' is a secondary dictionary which |
contains tuples of the form (type, default value) for the query |
arguments (this is the same dictionary as the one you can pass to |
webinterface_handler.wash_urlargd). |
When a query element has its default value, it is discarded, so |
that the simplest (canonical) url query is returned. |
The result contains the initial '?' if there are actual query |
items remaining. |
"""""" |
canonical = drop_default_urlargd(urlargd, default_urlargd) |
if canonical: |
return '?' + urlencode(canonical, doseq=True) |
# FIXME double escaping of '&'? .replace('&', '&') |
return ''" |
4737,"def create_html_link(urlbase, urlargd, link_label, linkattrd=None, |
escape_urlargd=True, escape_linkattrd=True, |
urlhash=None): |
""""""Creates a W3C compliant link. |
@param urlbase: base url (e.g. config.CFG_SITE_URL/search) |
@param urlargd: dictionary of parameters. (e.g. p={'recid':3, 'of'='hb'}) |
@param link_label: text displayed in a browser (has to be already escaped) |
@param linkattrd: dictionary of attributes (e.g. a={'class': 'img'}) |
@param escape_urlargd: boolean indicating if the function should escape |
arguments (e.g. < becomes < or "" becomes ") |
@param escape_linkattrd: boolean indicating if the function should escape |
attributes (e.g. < becomes < or "" becomes ") |
@param urlhash: hash string to add at the end of the link |
"""""" |
attributes_separator = ' ' |
output = '<a href=""' + \ |
create_url(urlbase, urlargd, escape_urlargd, urlhash) + '""' |
if linkattrd: |
output += ' ' |
if escape_linkattrd: |
attributes = [escape(str(key), quote=True) + '=""' + |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.