Re: [PATCH nft] py: fix missing decode/encode of strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Wed, May 01, 2019 at 12:35:00PM -0400, Eric Garver wrote:
> When calling ffi functions we need to convert from python strings to
> utf-8. Then convert back for any output we receive.

So the problem is passing utf-8 encoded strings as command?

[...]
> -        rc = self.nft_run_cmd_from_buffer(self.__ctx, cmdline)
> -        output = self.nft_ctx_get_output_buffer(self.__ctx)
> -        error = self.nft_ctx_get_error_buffer(self.__ctx)
> +        rc = self.nft_run_cmd_from_buffer(self.__ctx, cmdline.encode("utf-8"))
> +        output = self.nft_ctx_get_output_buffer(self.__ctx).decode("utf-8")
> +        error = self.nft_ctx_get_error_buffer(self.__ctx).decode("utf-8")

Should the encoding be made configurable? I see encode() and decode()
parameters are optional, but as soon as I call them with a string
containing umlauts I get errors. So not sure if that would be an
alternative.

BTW, thanks for all these fixes!

Cheers, Phil



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux