MCPcopy Create free account
hub / github.com/apple/foundationdb / de4514

Function de4514

FDBLibTLS/FDBLibTLSVerify.cpp:46–130  ·  view source on GitHub ↗

Does not handle "raw" form (e.g. #28C4D1), only escaped text

Source from the content-addressed store, hash-verified

44
45// Does not handle "raw" form (e.g. #28C4D1), only escaped text
46static std::string de4514(std::string const& input, int start, int& out_end) {
47 std::string output;
48
49 if (input[start] == '#' || input[start] == ' ') {
50 out_end = start;
51 return output;
52 }
53
54 int space_count = 0;
55
56 for (int p = start; p < input.size();) {
57 switch (input[p]) {
58 case '\\': // Handle escaped sequence
59
60 // Backslash escaping nothing!
61 if (p == input.size() - 1) {
62 out_end = p;
63 goto FIN;
64 }
65
66 switch (input[p + 1]) {
67 case ' ':
68 case '"':
69 case '#':
70 case '+':
71 case ',':
72 case ';':
73 case '<':
74 case '=':
75 case '>':
76 case '|':
77 case '\\':
78 output += input[p + 1];
79 p += 2;
80 space_count = 0;
81 continue;
82
83 default:
84 // Backslash escaping pair of hex digits requires two characters
85 if (p == input.size() - 2) {
86 out_end = p;
87 goto FIN;
88 }
89
90 try {
91 output += hexValue(input[p + 1]) * 16 + hexValue(input[p + 2]);
92 p += 3;
93 space_count = 0;
94 continue;
95 } catch (...) {
96 out_end = p;
97 goto FIN;
98 }
99 }
100
101 case '"':
102 case '+':
103 case ',':

Callers 1

parse_verifyMethod · 0.70

Calls 3

hexValueFunction · 0.70
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected