mirror of https://github.com/arendst/Tasmota.git
Berry `webserver.html_escape()` reusing the internal HTML escaping function (#18381)
This commit is contained in:
parent
0328915eab
commit
6007f2d970
|
@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
|
|||
### Added
|
||||
- Matter support for Light and Relays on ESP32 by Stephan Hadinger (#18320)
|
||||
- ESP32 WIP support for 16 shutters using `#define USE_SHUTTER_ESP32` in addition to `USE_SHUTTER` by Stefan Bode (#18295)
|
||||
- Berry `webserver.html_escape()` reusing the internal HTML escaping function
|
||||
|
||||
### Breaking Changed
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ extern int w_webserver_content_flush(bvm *vm);
|
|||
extern int w_webserver_content_stop(bvm *vm);
|
||||
extern int w_webserver_content_button(bvm *vm);
|
||||
|
||||
extern int w_webserver_html_escape(bvm *vm);
|
||||
|
||||
extern int w_webserver_argsize(bvm *vm);
|
||||
extern int w_webserver_arg(bvm *vm);
|
||||
extern int w_webserver_arg_name(bvm *vm);
|
||||
|
@ -48,6 +50,8 @@ module webserver (scope: global) {
|
|||
content_stop, func(w_webserver_content_stop)
|
||||
content_button, func(w_webserver_content_button)
|
||||
|
||||
html_escape, func(w_webserver_html_escape)
|
||||
|
||||
arg_size, func(w_webserver_argsize)
|
||||
arg, func(w_webserver_arg)
|
||||
arg_name, func(w_webserver_arg_name)
|
||||
|
|
|
@ -247,6 +247,20 @@ extern "C" {
|
|||
be_raise(vm, kTypeError, nullptr);
|
||||
}
|
||||
|
||||
// Berry: `webserver.html_escape(string) -> string`
|
||||
//
|
||||
int32_t w_webserver_html_escape(struct bvm *vm);
|
||||
int32_t w_webserver_html_escape(struct bvm *vm) {
|
||||
int32_t argc = be_top(vm); // Get the number of arguments
|
||||
if (argc >= 1 && be_isstring(vm, 1)) {
|
||||
const char * text = be_tostring(vm, 1);
|
||||
String html = HtmlEscape(text);
|
||||
be_pushstring(vm, html.c_str());
|
||||
be_return(vm);
|
||||
}
|
||||
be_raise(vm, kTypeError, nullptr);
|
||||
}
|
||||
|
||||
// Berry: `webserver.args() -> int`
|
||||
//
|
||||
// Returns the number of arguments
|
||||
|
|
Loading…
Reference in New Issue