mirror of
https://git.sakamoto.pl/laudom/http.sh.git
synced 2025-08-07 14:13:31 +02:00
Compare commits
3 commits
981426d6c2
...
57ed8eadbf
Author | SHA1 | Date | |
---|---|---|---|
|
57ed8eadbf | ||
|
1801e05fd9 | ||
|
21f922f731 |
2 changed files with 19 additions and 15 deletions
|
@ -31,20 +31,22 @@ function render() {
|
||||||
# below check prevents the loop loading itself as a template.
|
# below check prevents the loop loading itself as a template.
|
||||||
# this is possibly not enough to prevent all recursions, but
|
# this is possibly not enough to prevent all recursions, but
|
||||||
# i see it as a last-ditch measure. so it'll do here.
|
# i see it as a last-ditch measure. so it'll do here.
|
||||||
if [[ "$file" == "$tplfile" ]]; then
|
|
||||||
subtemplate+="s${_tpl_ctrl}\{\{\#$key\}\}${_tpl_ctrl}I cowardly refuse to endlessly recurse\!${_tpl_ctrl}g;"
|
|
||||||
# elif [[ -f "$key" ]]; then
|
|
||||||
else
|
|
||||||
local i
|
local i
|
||||||
local IFS=''
|
local IFS=''
|
||||||
|
|
||||||
|
_old_tplfile="$tplfile"
|
||||||
_template_find_absolute_path "$key"
|
_template_find_absolute_path "$key"
|
||||||
|
if [[ "$(realpath "$tplfile")" == "$_old_tplfile" ]]; then
|
||||||
|
subtemplate+="s${_tpl_ctrl}\{\{\#$key\}\}${_tpl_ctrl}I cowardly refuse to endlessly recurse\!${_tpl_ctrl}g;"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# don't even try to include files below httpsh's root
|
||||||
|
[[ "$(realpath "$tplfile")" != "$(dirname "$(realpath "${cfg[namespace]}")")"* ]] && continue
|
||||||
local input="$(tr -d "${_tpl_ctrl}${_tpl_newline}" < "$tplfile" | sed 's/\&/<2F>UwU<77>/g')"
|
local input="$(tr -d "${_tpl_ctrl}${_tpl_newline}" < "$tplfile" | sed 's/\&/<2F>UwU<77>/g')"
|
||||||
garbage+="$input"$'\n'
|
garbage+="$input"$'\n'
|
||||||
input="$(tr $'\n' "${_tpl_newline}" <<< "$input")" # for another hack
|
input="$(tr $'\n' "${_tpl_newline}" <<< "$input")" # for another hack
|
||||||
subtemplate+="s${_tpl_ctrl}\{\{\#$key\}\}${_tpl_ctrl}${input}${_tpl_ctrl};"
|
subtemplate+="s${_tpl_ctrl}\{\{\#$key\}\}${_tpl_ctrl}${input}${_tpl_ctrl};"
|
||||||
_template_find_special_uri "$(cat "$tplfile")"
|
_template_find_special_uri "$(cat "$tplfile")"
|
||||||
fi
|
|
||||||
done <<< "$(grep -Poh '{{#\K(.*?)(?=}})' <<< "$template")"
|
done <<< "$(grep -Poh '{{#\K(.*?)(?=}})' <<< "$template")"
|
||||||
|
|
||||||
buf+="${subtemplate}"
|
buf+="${subtemplate}"
|
||||||
|
@ -138,8 +140,10 @@ function render() {
|
||||||
#
|
#
|
||||||
# _template_find_absolute_path(name) -> $tplfile
|
# _template_find_absolute_path(name) -> $tplfile
|
||||||
_template_find_absolute_path() {
|
_template_find_absolute_path() {
|
||||||
if [[ ! "${template_relative_paths}" || "$1" == /dev/stdin || "$1" == "/dev/fd/"* ]]; then
|
if [[ "$1" == /dev/stdin || "$1" == "/dev/fd/"* ]]; then
|
||||||
tplfile="$1"
|
tplfile="$1"
|
||||||
|
elif [[ ! "${template_relative_paths}" ]]; then
|
||||||
|
tplfile="${cfg[namespace]}/$1"
|
||||||
else
|
else
|
||||||
for (( i=0; i<${#template_relative_paths[@]}; i++ )); do
|
for (( i=0; i<${#template_relative_paths[@]}; i++ )); do
|
||||||
if [[ -f "${template_relative_paths[i]}/$1" ]]; then
|
if [[ -f "${template_relative_paths[i]}/$1" ]]; then
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
HTTPSH_VERSION=0.97.1
|
HTTPSH_VERSION=0.97.2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue