Skip to content

A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol

add methods to normalize line and verify http scheme

Geo5fdad848aa8a
diff --git a/src/Transformers/ArgTransformer.cpp b/src/Transformers/ArgTransformer.cpp
index ca73c240..e2889fda 100644
--- a/src/Transformers/ArgTransformer.cpp
+++ b/src/Transformers/ArgTransformer.cpp
@@ -351,4 +351,24 @@ bool ArgTransformer::parseMac(const std::string& s, std::array<uint8_t,6>& out)
out[i] = (uint8_t)((hi<<4) | lo);
}
return true;
+}
+
+std::string ArgTransformer::ensureHttpScheme(std::string u) {
+ if (u.rfind("http://", 0) != 0 && u.rfind("https://", 0) != 0) {
+ u = "https://" + u; // defaut https
+ }
+ return u;
+}
+
+std::string ArgTransformer::normalizeLines(const std::string& in) {
+ std::string out;
+ out.reserve(in.size() * 2); // pire cas : tout '\n' doublé
+ for (size_t i = 0; i < in.size(); i++) {
+ if (in[i] == '\n') {
+ out += "\r\n";
+ } else {
+ out += in[i];
+ }
+ }
+ return out;
}
\ No newline at end of file
diff --git a/src/Transformers/ArgTransformer.h b/src/Transformers/ArgTransformer.h
index 2130b893..9272267d 100644
--- a/src/Transformers/ArgTransformer.h
+++ b/src/Transformers/ArgTransformer.h
@@ -33,4 +33,6 @@ public:
std::string toAsciiLine(uint32_t address, const std::vector<uint8_t>& line);
std::string toAsciiLine(uint32_t startAddr, const std::vector<uint16_t>& words);
bool parseMac(const std::string& s, std::array<uint8_t,6>& out);
+ std::string ensureHttpScheme(std::string u);
+ std::string normalizeLines(const std::string& in);
};