GCC Code Coverage Report


Directory: ./
File: libs/http/src/server/escape_html.cpp
Date: 2026-01-20 00:11:35
Exec Total Coverage
Lines: 0 25 0.0%
Functions: 0 1 0.0%
Branches: 0 15 0.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2025 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/cppalliance/http
8 //
9
10 #include <boost/http/server/escape_html.hpp>
11
12 namespace boost {
13 namespace http {
14
15 std::string
16 escape_html( core::string_view s )
17 {
18 std::string result;
19 result.reserve( s.size() );
20
21 for( char c : s )
22 {
23 switch( c )
24 {
25 case '&':
26 result.append( "&amp;" );
27 break;
28 case '<':
29 result.append( "&lt;" );
30 break;
31 case '>':
32 result.append( "&gt;" );
33 break;
34 case '"':
35 result.append( "&quot;" );
36 break;
37 case '\'':
38 result.append( "&#39;" );
39 break;
40 default:
41 result.push_back( c );
42 break;
43 }
44 }
45
46 return result;
47 }
48
49 } // http
50 } // boost
51