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