MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / html_escape

Function html_escape

crates/openshell-server/src/auth/http.rs:387–400  ·  view source on GitHub ↗

Minimal HTML attribute escaping for untrusted values. Escapes `&`, `"`, `'`, `<`, and `>` so the value is safe for embedding inside a quoted HTML attribute.

(s: &str)

Source from the content-addressed store, hash-verified

385/// Escapes `&`, `"`, `'`, `<`, and `>` so the value is safe for embedding
386/// inside a quoted HTML attribute.
387fn html_escape(s: &str) -> String {
388 let mut out = String::with_capacity(s.len());
389 for ch in s.chars() {
390 match ch {
391 '&' => out.push_str("&amp;"),
392 '"' => out.push_str("&quot;"),
393 '\'' => out.push_str("&#x27;"),
394 '<' => out.push_str("&lt;"),
395 '>' => out.push_str("&gt;"),
396 c => out.push(c),
397 }
398 }
399 out
400}
401
402/// Render a waiting page shown when the edge proxy auth cookie is not yet present.
403///

Callers 3

auth_connectFunction · 0.85
render_connect_pageFunction · 0.85
render_waiting_pageFunction · 0.85

Calls 2

lenMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected