Mercurial > dovecot > core-2.2
annotate src/lib/str-sanitize.h @ 23007:36e01285b5b8
lib: buffer - Improve header comment for buffer_insert() and buffer_delete().
author | Stephan Bosch <stephan.bosch@dovecot.fi> |
---|---|
date | Mon, 18 Mar 2019 00:52:37 +0100 |
parents | a556724ce39b |
children |
rev | line source |
---|---|
6410
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
2689
diff
changeset
|
1 #ifndef STR_SANITIZE_H |
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
2689
diff
changeset
|
2 #define STR_SANITIZE_H |
2689
631611c2d6e6
Added string sanitization functions.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 |
631611c2d6e6
Added string sanitization functions.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
4 /* All control characters in src will be appended as '?'. If src is longer |
18207
081c7da83d8f
lib: str_sanitize*() max_len parameter renamed to max_bytes to describe it more accurately.
Timo Sirainen <tss@iki.fi>
parents:
7002
diff
changeset
|
5 than max_bytes, it's truncated with "..." appended to the end. Note that |
081c7da83d8f
lib: str_sanitize*() max_len parameter renamed to max_bytes to describe it more accurately.
Timo Sirainen <tss@iki.fi>
parents:
7002
diff
changeset
|
6 src is treated as UTF-8 input, but max_bytes is in bytes instead of |
081c7da83d8f
lib: str_sanitize*() max_len parameter renamed to max_bytes to describe it more accurately.
Timo Sirainen <tss@iki.fi>
parents:
7002
diff
changeset
|
7 UTF-8 characters. */ |
081c7da83d8f
lib: str_sanitize*() max_len parameter renamed to max_bytes to describe it more accurately.
Timo Sirainen <tss@iki.fi>
parents:
7002
diff
changeset
|
8 void str_sanitize_append(string_t *dest, const char *src, size_t max_bytes); |
22922
a556724ce39b
lib: Implement str_sanitize_utf8().
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
18207
diff
changeset
|
9 /* All control characters in src will be appended as the unicode replacement |
a556724ce39b
lib: Implement str_sanitize_utf8().
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
18207
diff
changeset
|
10 character (U+FFFD). If src has more than max_cps unicode code points, it's |
a556724ce39b
lib: Implement str_sanitize_utf8().
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
18207
diff
changeset
|
11 truncated with a horizontal ellipsis character (U+2026) appended to the end. |
a556724ce39b
lib: Implement str_sanitize_utf8().
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
18207
diff
changeset
|
12 */ |
a556724ce39b
lib: Implement str_sanitize_utf8().
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
18207
diff
changeset
|
13 void str_sanitize_append_utf8(string_t *dest, const char *src, |
a556724ce39b
lib: Implement str_sanitize_utf8().
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
18207
diff
changeset
|
14 uintmax_t max_cps); |
7002
f359a0a9407f
str_sanitize*(): Don't crash if max_len is less than 3.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
15 /* Return src sanitized. If there are no changes, src pointer is returned. |
f359a0a9407f
str_sanitize*(): Don't crash if max_len is less than 3.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
16 If src is NULL, returns NULL. */ |
18207
081c7da83d8f
lib: str_sanitize*() max_len parameter renamed to max_bytes to describe it more accurately.
Timo Sirainen <tss@iki.fi>
parents:
7002
diff
changeset
|
17 const char *str_sanitize(const char *src, size_t max_bytes); |
22922
a556724ce39b
lib: Implement str_sanitize_utf8().
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
18207
diff
changeset
|
18 /* The unicode version of str_sanitize() using str_sanitize_append_utf8() |
a556724ce39b
lib: Implement str_sanitize_utf8().
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
18207
diff
changeset
|
19 internally. */ |
a556724ce39b
lib: Implement str_sanitize_utf8().
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
18207
diff
changeset
|
20 const char *str_sanitize_utf8(const char *src, uintmax_t max_cps); |
2689
631611c2d6e6
Added string sanitization functions.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
21 |
631611c2d6e6
Added string sanitization functions.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
22 #endif |