MCPcopy Create free account
hub / github.com/apache/brpc / WebEscape

Function WebEscape

src/brpc/controller.cpp:1484–1496  ·  view source on GitHub ↗

TODO: Need more security advices from professionals. TODO: Is percent encoding better?

Source from the content-addressed store, hash-verified

1482// TODO: Need more security advices from professionals.
1483// TODO: Is percent encoding better?
1484void WebEscape(const std::string& source, std::string* output) {
1485 output->reserve(source.length() + 10);
1486 for (size_t pos = 0; pos != source.size(); ++pos) {
1487 switch (source[pos]) {
1488 case '&': output->append("&"); break;
1489 case '\"': output->append("""); break;
1490 case '\'': output->append("'"); break;
1491 case '<': output->append("&lt;"); break;
1492 case '>': output->append("&gt;"); break;
1493 default: output->push_back(source[pos]); break;
1494 }
1495 }
1496}
1497
1498std::string WebEscape(const std::string& source) {
1499 std::string output;

Callers 5

ProcessHttpRequestFunction · 0.85
PrintAnnotationsFunction · 0.85
PrintClientSpanFunction · 0.85
PrintServerSpanFunction · 0.85
default_methodMethod · 0.85

Calls 5

reserveMethod · 0.45
lengthMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected