-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: fmrl
action: commit
revision:
path_from:
revision_from: 7b247ec724d32ba1ce717a560a7c94abdb1d8c55:
path_to:
revision_to:

git.thebackupbox.net

fmrl

git://git.thebackupbox.net/fmrl

commit 7b247ec724d32ba1ce717a560a7c94abdb1d8c55
Author: epoch <epoch@hack.thebackupbox.net>
Date:   Fri Jan 7 04:52:25 2022 +0000

    /actually/ escaped the double-quotes, decoded html entities and re-encoded them to get emojis to be not be encoded. set charset=utf-8 on all responses

diff --git a/index.cgi b/index.cgi

index f8cc021ba02689c80986b1c5ab883cfc266240b8..

index ..b952cf68e6b9a77e3de05d89513801eb5470b694 100755

--- a/index.cgi
+++ b/index.cgi
@@ -18,11 +18,11 @@ case "$PATH_INFO" in
     fi
   fi
   printf "Last-Modified: %s\r\n" "$(rfc7231date "${last_modified}")"
-  printf "Content-Type: application/json\r\n\r\n"
+  printf "Content-Type: application/json; charset=utf-8\r\n\r\n"
   cat "${user_file}"
 ;;
 /update/)
-  printf "Content-Type: text/html\r\n\r\n"
+  printf "Content-Type: text/html; charset=utf-8\r\n\r\n"
   . /var/www/lib/remote_host.cgi
   if [ "$REQUEST_METHOD" = "POST" ];then
     export QUERY_STRING="$(head -c "$HTTP_CONTENT_LENGTH")"
@@ -44,24 +44,24 @@ case "$PATH_INFO" in
       fi
     fi

-    name="$(query_param name | tr '+' ' ' | uriunescape | sed 's|"|\"|g')"
+    name="$(query_param name | tr '+' ' ' | uriunescape | sed 's|"|\\"|g')"
     if [ ! "$name" ];then
-      name="$(cat ".users/${REMOTE_IDENT}" | jq -r .name | sed 's|"|\"|g')"
+      name="$(cat ".users/${REMOTE_IDENT}" | jq -r .name | sed 's|"|\\"|g')"
     fi

-    status="$(query_param status | tr '+' ' ' | uriunescape | sed 's|"|\"|g')"
+    status="$(query_param status | tr '+' ' ' | uriunescape | sed 's|"|\\"|g')"
     if [ ! "$status" ];then
-      status="$(cat ".users/${REMOTE_IDENT}" | jq -r .status | sed 's|"|\"|g')"
+      status="$(cat ".users/${REMOTE_IDENT}" | jq -r .status | sed 's|"|\\"|g')"
     fi

-    emoji="$(query_param emoji | uriunescape | sed 's|"|\"|g')"
+    emoji="$(query_param emoji | uriunescape | html_entities_decode | html_entities_encode | sed 's|"|\\"|g')"
     if [ ! "$emoji" ];then
-      emoji="$(cat ".users/${REMOTE_IDENT}" | jq -r .emoji | sed 's|"|\"|g')"
+      emoji="$(cat ".users/${REMOTE_IDENT}" | jq -r .emoji | sed 's|"|\\"|g')"
     fi

-    media="$(query_param media | uriunescape | sed 's|"|\"|g')"
+    media="$(query_param media | uriunescape | sed 's|"|\\"|g')"
     if [ ! "$media" ];then
-      media="$(cat ".users/${REMOTE_IDENT}" | jq -r .media | sed 's|"|\"|g')"
+      media="$(cat ".users/${REMOTE_IDENT}" | jq -r .media | sed 's|"|\\"|g')"
     fi

     media_type="$(query_param media_type | tr -cd '0-9')"
@@ -88,7 +88,7 @@ END
   fi

   printf "you are connecting from: %s ( %s )<br/>\n" "$REMOTE_ADDR" "$REMOTE_HOST"
-  if [ "$REMOTE_HOST" = "lin.thebackupbox.net." -o "$REMOTE_HOST" = "::ffff:127.0.0.1" -o "$REMOTE_HOST" = "shell.xshellz.com." ];then
+  if [ "$REMOTE_HOST" = "lin.thebackupbox.net." -o "$REMOTE_HOST" = "::ffff:127.0.0.1" -o "$REMOTE_HOST" = "shell.xshellz.com." -o "$REMOTE_ADDR" = "192.168.1.60" ];then
     echo "make sure you have a working ident daemon running that responds with the username you want to update<br/>"
     if [ "$REQUEST_METHOD" = "POST" ];then
       echo "updating with:"
@@ -128,7 +128,7 @@ leave fields blank if you don't want to update them.<br/>
 EOF
 ;;
 *)
-  printf "Content-Type: application/json\r\n\r\n"
+  printf "Content-Type: application/json; charset=utf-8\r\n\r\n"
   printf "{\n"
 #  i=0
   printf "%s\n" "$QUERY_STRING" | tr '&' '\n' | grep ^user= | cut -d= -f2- | sort | uniq | while read user;do
@@ -143,7 +143,7 @@ EOF
 esac
 exit 0
 fi
-printf "Content-Type: text/html\r\n\r\n"
+printf "Content-Type: text/html; charset=utf-8\r\n\r\n"

 echo '<html>'
 echo '<head>'

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 18:28:27 2024