ton-blockchain / ton

Main TON monorepo
Other
2.95k stars 891 forks source link

How fift can accept zero bytes as argv #143

Closed vird closed 2 years ago

vird commented 4 years ago

Seems there is no easy way to call command line tools with argv with zero bytes. related stuff: https://unix.stackexchange.com/questions/344829/using-binary-data-as-a-parameter-in-bash-any-way-to-allow-nuls

Can we use dots in DNS challenge insted of \0?

ghost commented 4 years ago

You can accept the parameter with dots and then replace dots by null bytes. "A.B.C" -> "A\0B\0C\0".

ton-blockchain commented 4 years ago

Yes, if the problem is only in parsing the command line argument of a Fift script, you can use the suggestion above:

// ( S -- S' )  Replaces all dots in S with null characters
recursive dots-to-nulls {  
  dup $len { 1 $| dots-to-nulls swap dup "." $= { drop B{00} B>$ } if swap $+ } if
} swap !

"test.google.com" dots-to-nulls $>B Bx.
7465737400676F6F676C6500636F6D ok