1. Moritz Wilhelmy
  2. lua-bencode
  3. Issues
Issue #7 resolved

does not decode negative integers

created an issue

This script explodes:

local bencode = require 'bencode' local from =-1 print (from) local s=assert(bencode.encode(from)) print (s) local out =assert(bencode.decode(s)) print (out)


$ lua testbencode.lua -1 i-1e lua: testbencode.lua:9: not a number stack traceback: [C]: in function 'assert' testbencode.lua:9: in main chunk [C]: ?

Solved changing the pattern at line 115 to

local a, b, int = find(s, "^(%-?[0-9]+)e", index)

Comments (3)

  1. Moritz Wilhelmy repo owner

    Please note, this is important enough for me to make another release. New version number will be 2.0, because I made some incompatible changes (most importantly returning nil instead of having error() all over the place). Nice to actually see someone use it.

  2. Log in to comment