This commit is contained in:
Philippe Teuwen
2026-03-02 12:50:34 +01:00
parent fee0467ad7
commit e2b11e937f
3 changed files with 35 additions and 31 deletions
+1 -1
View File
@@ -1759,7 +1759,7 @@ int CmdHW(const char *Cmd) {
void pm3_version_short(void) {
// PrintAndLogEx(NORMAL, " [ " _CYAN_("Proxmark3 RFID instrument") " ]");
PrintAndLogEx(NORMAL, " [ " _CYAN_("Proxmark3") " ]");
PrintAndLogEx(NORMAL, " [ " _CYAN_(_URL_("https://github.com/RfidResearchGroup/proxmark3", "Proxmark3")) " ]");
PrintAndLogEx(NORMAL, "");
if (g_session.pm3_present) {
+32 -30
View File
@@ -527,40 +527,42 @@ void memcpy_filter_rlmarkers(void *dest, const void *src, size_t n) {
}
void memcpy_filter_ansi(void *dest, const void *src, size_t n, bool filter) {
if (filter) {
// Filter out ANSI sequences on these OS
uint8_t *rdest = (uint8_t *)dest;
uint8_t *rsrc = (uint8_t *)src;
uint16_t si = 0;
for (size_t i = 0; i < n; i++) {
if ((i < n - 1)
&& (rsrc[i] == '\x1b')
&& (rsrc[i + 1] >= 0x40)
&& (rsrc[i + 1] <= 0x5F)) { // entering ANSI sequence
i++;
if ((i < n - 1) && (rsrc[i] == '[')) { // entering CSI sequence
i++;
while ((i < n - 1) && (rsrc[i] >= 0x30) && (rsrc[i] <= 0x3F)) { // parameter bytes
i++;
}
while ((i < n - 1) && (rsrc[i] >= 0x20) && (rsrc[i] <= 0x2F)) { // intermediate bytes
i++;
}
if ((rsrc[i] >= 0x40) && (rsrc[i] <= 0x7F)) { // final byte
continue;
}
} else {
if (!filter) {
memcpy(dest, src, n);
return;
}
uint8_t *rdest = (uint8_t *)dest;
const uint8_t *rsrc = (const uint8_t *)src;
size_t si = 0;
for (size_t i = 0; i < n; i++) {
if (rsrc[i] == '\x1b' && i < n - 1) {
/* ----- CSI sequence ----- */
if (rsrc[i + 1] == '[') {
i += 2;
while (i < n && rsrc[i] >= 0x30 && rsrc[i] <= 0x3F) i++;
while (i < n && rsrc[i] >= 0x20 && rsrc[i] <= 0x2F) i++;
if (i < n && rsrc[i] >= 0x40 && rsrc[i] <= 0x7F) {
continue;
}
}
rdest[si++] = rsrc[i];
/* ----- OSC sequence (used for hyperlinks) ----- */
else if (rsrc[i + 1] == ']') {
i += 2;
/* OSC terminates with BEL or ESC \ */
while (i < n) {
if (rsrc[i] == '\x07') // BEL
break;
if (rsrc[i] == '\x1b' && i + 1 < n && rsrc[i + 1] == '\\') {
i++; // consume '\'
break;
}
i++;
}
continue;
}
}
} else {
memcpy(dest, src, n);
rdest[si++] = rsrc[i];
}
}
+2
View File
@@ -79,4 +79,6 @@
#define _RL_BOLD_RED_(s) RL_ESC("\x1b[1;31m") s RL_ESC(AEND)
#define _RL_BOLD_GREEN_(s) RL_ESC("\x1b[1;32m") s RL_ESC(AEND)
#define _URL_(url, text) "\x1b]8;;" url "\x1b\\" text "\x1b]8;;\x1b\\"
#endif