-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathescape_html.cpp
More file actions
50 lines (44 loc) · 1.01 KB
/
escape_html.cpp
File metadata and controls
50 lines (44 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/cppalliance/http
//
#include <boost/http/server/escape_html.hpp>
namespace boost {
namespace http {
std::string
escape_html( core::string_view s )
{
std::string result;
result.reserve( s.size() );
for( char c : s )
{
switch( c )
{
case '&':
result.append( "&" );
break;
case '<':
result.append( "<" );
break;
case '>':
result.append( ">" );
break;
case '"':
result.append( """ );
break;
case '\'':
result.append( "'" );
break;
default:
result.push_back( c );
break;
}
}
return result;
}
} // http
} // boost