boltcard / bolt-nfc-android-app

Program your bolt card easily from your android mobile with this app
MIT License
36 stars 14 forks source link

some nullbytes are added in the callback when write the card #40

Open nicolasburtey opened 1 year ago

nicolasburtey commented 1 year ago

here is an example of a callback:

https://localhost:3000/api/ln?p=9E7F7FBADE31A687A8E8525773139055&c=886FDB3E8AA51797%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00

The code to remove it with node is:

  const raw_c = searchParams.get("c")
  const raw_c_decoded = decodeURIComponent(raw_c)
  const raw_c_nonullbytes = raw_c_decoded.replace(/\x00+$/, "")

not sure why this happen but not having those null value would be better. took me a bit of time to debug this; this was the reason the callback was not working properly on my end initially.

robertclarkson commented 1 year ago

This is a strange one but is actually intentional, this is due to compatibility with the either intentional-or-bug with the first ever implementation by Coin Corner.

Could potentially be to stop the NDEF being "recognised" by the operating system and redirecting to the browser or similar? maybe @PeterRounce has more info?

robertclarkson commented 1 year ago

Actually sorry disregard this, I thought you were talking about null bytes at the start of the NDEF record. unsure where those null bytes are coming from exactly...