Squid Web Cache master
Loading...
Searching...
No Matches
rfc1738.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2026 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef SQUID_INCLUDE_RFC1738_H
10#define SQUID_INCLUDE_RFC1738_H
11
12/* Encoder rfc1738_do_escape flag values. */
13#define RFC1738_ESCAPE_CTRLS 1
14#define RFC1738_ESCAPE_UNSAFE 2
15#define RFC1738_ESCAPE_RESERVED 4
16#define RFC1738_ESCAPE_ALL (RFC1738_ESCAPE_UNSAFE|RFC1738_ESCAPE_RESERVED|RFC1738_ESCAPE_CTRLS)
17// exclusions
18#define RFC1738_ESCAPE_NOSPACE 128
19#define RFC1738_ESCAPE_NOPERCENT 256
20// Backward compatibility
21#define RFC1738_ESCAPE_UNESCAPED (RFC1738_ESCAPE_UNSAFE|RFC1738_ESCAPE_CTRLS|RFC1738_ESCAPE_NOPERCENT)
22
43extern char *rfc1738_do_escape(const char *url, int flags);
44
45/* Old API functions */
46
47/* Default RFC 1738 escaping. Escape all UNSAFE characters and binary CTRL codes */
48#define rfc1738_escape(x) rfc1738_do_escape(x, RFC1738_ESCAPE_UNSAFE|RFC1738_ESCAPE_CTRLS)
49
50/* Escape a partial URL. Encoding every binary code, unsafe or reserved character. */
51#define rfc1738_escape_part(x) rfc1738_do_escape(x, RFC1738_ESCAPE_ALL)
52
53/* Escape a URL. Encoding every unsafe characters but skipping reserved and already-encoded bytes.
54 * Suitable for safely encoding an absolute URL which may be encoded but is not trusted. */
55#define rfc1738_escape_unescaped(x) rfc1738_do_escape(x, RFC1738_ESCAPE_UNSAFE|RFC1738_ESCAPE_CTRLS|RFC1738_ESCAPE_NOPERCENT)
56
61extern void rfc1738_unescape(char *url);
62
63#endif /* SQUID_INCLUDE_RFC1738_H */
64
char * rfc1738_do_escape(const char *url, int flags)
Definition rfc1738.cc:56
void rfc1738_unescape(char *url)
Definition rfc1738.cc:146