diff --git a/httpd/page_impl.c b/httpd/page_impl.c index 1ed36c51..58624145 100644 --- a/httpd/page_impl.c +++ b/httpd/page_impl.c @@ -70,6 +70,13 @@ void char_to_html(char c) } +static void str_x_to_html(__xdata const char *s) +{ + while (*s) + outbuf[slen++] = *s++; +} + + void json_char_to_html(uint8_t c) { if (c < 0x20 || c > 0x7e || c == '"' || c == '\\') @@ -872,14 +879,11 @@ void send_status(void) sfp_send_data(sfp, 238, 1); } slen += strtox(outbuf + slen,"\",\"sfp_vendor\":\""); - for (uint8_t s = 0; s < 16 && sfp_module_vendor[sfp][s]; s++) - json_char_to_html(sfp_module_vendor[sfp][s]); + str_x_to_html(sfp_module_vendor[sfp]); slen += strtox(outbuf + slen,"\",\"sfp_model\":\""); - for (uint8_t s = 0; s < 16 && sfp_module_model[sfp][s]; s++) - json_char_to_html(sfp_module_model[sfp][s]); + str_x_to_html(sfp_module_model[sfp]); slen += strtox(outbuf + slen,"\",\"sfp_serial\":\""); - for (uint8_t s = 0; s < 16 && sfp_module_serial[sfp][s]; s++) - json_char_to_html(sfp_module_serial[sfp][s]); + str_x_to_html(sfp_module_serial[sfp]); slen += strtox(outbuf + slen,"\",\"sfp_los\":"); if (machine.sfp_port[sfp].pin_los == GPIO_NA) { slen += strtox(outbuf + slen,"null"); diff --git a/sfp.c b/sfp.c index 7bc4f301..1f1f6652 100644 --- a/sfp.c +++ b/sfp.c @@ -88,7 +88,12 @@ bool sfp_read_field(__xdata char *dst, uint8_t sfp, uint8_t start, uint8_t lengt return false; dst[length] = NUL; - memcpy(dst, sfp_buf, length); + for (uint8_t i = 0; i < length; i++) { + uint8_t c = sfp_buf[i]; + if (c && (c < 0x20 || c > 0x7e || c == '"' || c == '\\')) + c = '.'; + dst[i] = c; + } while (length > 0 && dst[--length] == ' ') dst[length] = NUL;