summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormykola.salomatin <mykola.salomatin@globallogic.com>2021-01-19 17:01:46 +0200
committermykola.salomatin <mykola.salomatin@globallogic.com>2021-01-19 17:01:46 +0200
commit9c6f78b046962c13584f1c35ba253749f1cb9585 (patch)
treeb9490a31f172c18a421200889e4d18673056307f /src
parent7ba216743f5a413ff3093cfe169718894836cb62 (diff)
downloadlibmts-9c6f78b046962c13584f1c35ba253749f1cb9585.tar.gz
libmts-9c6f78b046962c13584f1c35ba253749f1cb9585.tar.bz2
libmts-9c6f78b046962c13584f1c35ba253749f1cb9585.zip
[MTX-3785] mPower R.5.4: GP-971 - Device shall implement file type restrictions for all “upload” sections on the UI
LoRaWAN components: LoraLicense (.lic), LoraFotaFile (.bin), LoraMulticast (.bin for Binary, .txt for Hexadecimal and Base64), LoraGroup (.json) validated by file extension.
Diffstat (limited to 'src')
-rw-r--r--src/MTS_Text.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/MTS_Text.cpp b/src/MTS_Text.cpp
index d823bfe..8dcb85f 100644
--- a/src/MTS_Text.cpp
+++ b/src/MTS_Text.cpp
@@ -699,3 +699,10 @@ bool Text::parseHex(uint64_t& value, const std::string& str) {
return ((uint8_t) ss.rdstate() == RDSTATE_SUCCESS_MASK);
}
+std::string Text::getFileExtension(const std::string& filename) {
+ size_t pos = filename.rfind('.', filename.length());
+ if (pos != std::string::npos) {
+ return (filename.substr(pos + 1, filename.length() - pos));
+ }
+ return ("");
+}