diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-09-05 19:50:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-05 19:50:43 +0200 |
commit | 3c9c1d909476896b16ba750090f042e7824b50b2 (patch) | |
tree | bdddf72f0cce5b1b309bb61fc60a7f0bf77d8bb1 /vespalib/src/vespa/vespalib/util/string_escape.h | |
parent | b81ed9944fd93513b18c48f8fc84d9aeec8615a5 (diff) | |
parent | 506f285043535af5d81fd098dfd28166930704e5 (diff) |
Merge pull request #23934 from vespa-engine/vekterli/factor-out-xml-string-escapingv8.48.22
Factor out XML string escaping and use for internal legacy status pages [run-systemtest]
Diffstat (limited to 'vespalib/src/vespa/vespalib/util/string_escape.h')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/string_escape.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/util/string_escape.h b/vespalib/src/vespa/vespalib/util/string_escape.h new file mode 100644 index 00000000000..3ad926dafc4 --- /dev/null +++ b/vespalib/src/vespa/vespalib/util/string_escape.h @@ -0,0 +1,26 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +#include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/stllike/string.h> +#include <iosfwd> + +namespace vespalib { + +/** + * Returns input string but where the following characters are escaped: + * - all control chars < char value 32 + * - <, >, &, " and ' + */ +[[nodiscard]] vespalib::string xml_attribute_escaped(vespalib::stringref s); + +/** + * Returns input string but where the following characters are escaped: + * - all control chars < char value 32, _except_ linebreak + * - <, > and & + */ +[[nodiscard]] vespalib::string xml_content_escaped(vespalib::stringref s); +void write_xml_content_escaped(vespalib::asciistream& out, vespalib::stringref s); +void write_xml_content_escaped(std::ostream& out, vespalib::stringref s); + +} |