What is Nostr?
Leonard/Janis Robert König /
npub1uf6…774h
2024-12-29 17:34:56
in reply to nevent1q…0z4s

Leonard/Janis Robert König on Nostr: nprofile1q…vss2n Finally found the culprit, the following code should work :) ``` ...

nprofile1qy2hwumn8ghj7un9d3shjtnddaehgu3wwp6kyqpq6mtxp68k8c3p2sj0wzhagt3kd8ywkvzlkfyt3vrx9cahzfz000vsmvss2n (nprofile…ss2n) Finally found the culprit, the following code should work :)

```
#! /bin/sh

# Dependencies:
# * cURL
# * htmlq: https://github.com/mgdm/htmlq

ENDPOINT='https://flask.io';

if [ "$#" -ne 2 ]; then
printf 'newtask <flask ID> <new item name>\n' >&2
exit 1
fi

flasklist="$1"
item="$2"

cookies="/tmp/flasker_cookiejar_$flasklist.txt"
csrf_token=$(curl --silent -c "$cookies" -b "$cookies" "$ENDPOINT/$flasklist" | htmlq --attribute 'content' 'meta[name=csrf-token]')

# 1. We do want to URL-Encode the checkmark emoji
# 2. We also want to encode "$item" but the [], too, so we pre-encode it
# 3. We do want to encode "Save Task" but cURL encodes space as "+" and not %20
# so we pre-encode it and prevent re-encoding through cURL.
curl --silent \
-c "$cookies" \
-b "$cookies" \
-H "X-Csrf-Token: $csrf_token" \
--data-urlencode "utf8=✓" \
--data-urlencode "task%5Bdescription%5D=$item" \
--data-urlencode "=commit=Save%20Task" \
"$ENDPOINT/$flasklist/tasks"
```

Short explanation: You also need to send the X-Csrf-Token which we need to parse from the HTML. Also some of the data needs to be differently encoded :)
Author Public Key
npub1uf6cu9nwq4tvcrgeahfxf2mx9ppq4nxdldf22a0kmhtuk7dq2mjqmm774h