Commit graph

29 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 80ab31a435 shared/utf8: add utf8_is_valid_n()
Sometimes we need to check strings without the terminating NUL. Add a variant
that does that.
2020-09-01 16:48:40 +02:00
Zbigniew Jędrzejewski-Szmek 62a3fc6d27 shared/logs-show: strip trailing carriage returns at EOL/EOF
When showing logs from a container, we would fail to show various lines:
Oct 29 09:50:51 krowka systemd-nspawn[61376]: Detected architecture x86-64.
Oct 29 09:50:51 krowka systemd-nspawn[61376]: [1B blob data]
Oct 29 09:50:51 krowka systemd-nspawn[61376]: Welcome to Fedora 32 (Rawhide)!
Oct 29 09:50:51 krowka systemd-nspawn[61376]: [1B blob data]

Those are only harmless \r characters that trail the line. We already replace
tabs and strip various ansi characters that we deem inconsequential, so let's
also strip trailing carriage returns. Non-trailing ones are different, because
they change what would be displayed.
2019-10-29 10:54:45 +01:00
Zbigniew Jędrzejewski-Szmek da88f542d9 util-lib: add truncation based on printable width to utf8_escape_non_printable() 2019-05-22 09:50:19 +02:00
Zbigniew Jędrzejewski-Szmek 9743846e23 test-utf8: add function headers and rename tests after functions they test 2019-05-21 10:57:23 +02:00
Zbigniew Jędrzejewski-Szmek 92e068b465 basic/utf8: do not read past end of string when looking for a multi-byte character
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9341.
2019-02-26 12:37:40 +01:00
Lennart Poettering 80b0a59729 utf8: add utf8_to_utf16() helper 2018-09-25 15:57:47 +02:00
Zbigniew Jędrzejewski-Szmek 25612ecba4 tree-wide: drop copyright lines for more authors
Acks in https://github.com/systemd/systemd/issues/9320.
2018-06-22 16:39:45 +02:00
Lennart Poettering 96b2fb93c5 tree-wide: beautify remaining copyright statements
Let's unify an beautify our remaining copyright statements, with a
unicode ©. This means our copyright statements are now always formatted
the same way. Yay.
2018-06-14 10:20:21 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Zbigniew Jędrzejewski-Szmek 294a3121aa basic/utf8: add ascii_is_valid_n() 2018-06-09 13:41:24 +02:00
Zbigniew Jędrzejewski-Szmek 7c6c2e07fc test-utf8: add a smoke test for utf8_console_width() 2018-04-18 12:51:15 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00
Zbigniew Jędrzejewski-Szmek e2cbc803f0 tests: add a simple test for utf8_n_codepoints() 2018-02-19 15:18:54 +01:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Thomas Hindoe Paaboel Andersen cf0fbc49e6 tree-wide: sort includes
Sort the includes accoding to the new coding style.
2015-11-16 22:09:36 +01:00
Lennart Poettering b5efdb8af4 util-lib: split out allocation calls into alloc-util.[ch] 2015-10-27 13:45:53 +01:00
Lennart Poettering 07630cea1f util-lib: split our string related calls from util.[ch] into its own file string-util.[ch]
There are more than enough calls doing string manipulations to deserve
its own files, hence do something about it.

This patch also sorts the #include blocks of all files that needed to be
updated, according to the sorting suggestions from CODING_STYLE. Since
pretty much every file needs our string manipulation functions this
effectively means that most files have sorted #include blocks now.

Also touches a few unrelated include files.
2015-10-24 23:05:02 +02:00
Tom Gundersen 502184de0f test: utf8 - fix utf16 tests on BE machines 2015-02-18 15:23:23 +01:00
Tom Gundersen 04166cb7dd shared: utf8 - support decoding the full utf16
We originally only supported the BMP (i.e., we treated UTF-16 as UCS-2).
2014-12-22 20:26:53 +01:00
Lennart Poettering 3c6d3052d3 utf8: when escaping unprintable unichars, escape the whole unichar, not just the first byte of it 2014-12-04 02:27:14 +01:00
WaLyong Cho fec8457652 utf8: intruduce utf8_escape_non_printable 2014-12-04 02:09:44 +01:00
Zbigniew Jędrzejewski-Szmek 550a40eceb core: do not print invalid utf-8 in error messages 2014-02-08 13:07:39 -05:00
Lennart Poettering 23c62e05b3 utf8: ascii_filter() is unused, let's remove it 2013-11-07 03:06:37 +01:00
Zbigniew Jędrzejewski-Szmek a7176505e0 utf8: fix utf8_is_printable 2013-10-05 22:59:43 -04:00
Dave Reisner e7363c59d6 test-utf8: add more tests for public functions 2013-09-19 11:50:36 -04:00
Dave Reisner 8f6ce71fe7 device-nodes: move device node specific code to own file
In the process, rename udev_encode_string which is poorly named for what
it does. It deals specifically with encoding names that udev creates and
has its own rules: utf8 is valid but some ascii is not (e.g. path
separators), and everything else is simply escaped. Rename it to
encode_devnode_name.
2013-09-19 11:50:34 -04:00
Dave Reisner 7991ac34ab shared/utf8: merge implementations, remove cruft
This unifies the utf8 handling code which was previously duplicated in
udev and systemd.
2013-09-19 11:49:03 -04:00
Dave Reisner 02a36bc9a1 move utf8 functions from libudev-private.h to utf8.h
There's now some more obvious overlap amongst the two utf8 validation
functions, but no more than there already was previously.

This also adds some menial tests for anyone who wants to do more
merging of these two in the future.
2013-09-17 16:31:32 -04:00