File Coverage

src/panda/uri/parser_ext.rl
Criterion Covered Total %
statement 17 17 100.0
branch 4 8 50.0
condition n/a
subroutine n/a
pod n/a
total 21 25 84.0


line stmt bran cond sub pod time code
1             #include "parser.h"
2              
3             namespace panda { namespace uri {
4              
5             // ============== RFC3986 compliant parser ===================
6              
7             %%{
8             machine uri_parser_ext;
9             include uri_parser_base "parser.rl";
10            
11 10           action ext_chars { ext_chars = true; }
12 9          
13             query = (pchar | "/" | "?" | ("\"" | "{" | "}") %ext_chars)* >mark %query;
14 31 50         absolute_uri = scheme ":" hier_part ("?" query)? ("#" fragment)?;
    100          
    0          
15 1           relative_ref = relative_part ("?" query)? ("#" fragment)?;
16            
17             uri := absolute_uri | relative_ref;
18            
19             write data;
20             }%%
21              
22 1           bool URI::_parse_ext (const string& str, bool& authority_has_pct) {
23 1           const char* ps = str.data();
24 1           const char* p = ps;
25 1           const char* pe = p + str.length();
26 1           const char* eof = pe;
27 1           int cs = uri_parser_ext_start;
28             size_t mark;
29 1           int acc = 0;
30 1           bool ext_chars = false;
31            
32             %% write exec;
33            
34 1 50         if (ext_chars) { // we must parse and invalidate source query string to produce valid uri on output
35 1           parse_query();
36 1           _qstr.clear();
37 1           ok_query();
38             }
39            
40 1           return cs >= uri_parser_ext_first_final;
41             }
42              
43             }}