diff options
author | Freya Murphy <freya@freyacat.org> | 2024-11-26 11:45:12 -0500 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-11-26 11:45:12 -0500 |
commit | 82f911cf18c615d23d7a6934c36879e75f2cf46e (patch) | |
tree | 5171b3dbdedf96aee4740eeae03fec23b8d878aa /src/web/helpers/html.php | |
parent | add logout, better router (diff) | |
download | ldap_forwardauth-82f911cf18c615d23d7a6934c36879e75f2cf46e.tar.gz ldap_forwardauth-82f911cf18c615d23d7a6934c36879e75f2cf46e.tar.bz2 ldap_forwardauth-82f911cf18c615d23d7a6934c36879e75f2cf46e.zip |
new style, add redirect support
Diffstat (limited to 'src/web/helpers/html.php')
-rw-r--r-- | src/web/helpers/html.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/web/helpers/html.php b/src/web/helpers/html.php new file mode 100644 index 0000000..dc38e3a --- /dev/null +++ b/src/web/helpers/html.php @@ -0,0 +1,21 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ + +function is_base64(string $data): bool { + return base64_encode(base64_decode($data, true)) === $data; +} + +function maybe_base64_encode(string $data): string { + if (is_base64($data)) { + return $data; + } else { + return base64_encode($data); + } +} + +function esc(string $data): string { + $data = trim(preg_replace('/\s\s+/', ' ', $data)); + $data = str_replace('&', '&', $data); + $data = str_replace('<', '<', $data); + $data = str_replace('>', '>', $data); + return $data; +} |