Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimal Parameter unable to hold a signed number #866

Closed
curious-ninja opened this issue Apr 18, 2021 · 0 comments
Closed

Decimal Parameter unable to hold a signed number #866

curious-ninja opened this issue Apr 18, 2021 · 0 comments

Comments

@curious-ninja
Copy link

curious-ninja commented Apr 18, 2021

Hello,
While working on a custom module for bettercap, I noticed that the DecimalParameter is unable to hold a signed number.

The relevant code from my module:

if err, mod.battcurrent = mod.DecParam("health.battcurrent"); err != nil {
		return err
	}

Results in a validation error.

See:

return NewModuleParameter(name, def_value, FLOAT, "^[\\d]+(\\.\\d+)?$", desc)

I changed the line to:

return NewModuleParameter(name, def_value, FLOAT, `^[\-\+]?[\d]+(\.\d+)?$`, desc)

Environment

  • Bettercap version: 2.31.0

  • OS version and architecture: ARM 64 (Kali Linux on RPi4)

  • Go version: 1.16.3

  • Command line arguments you are using:
    sudo bettercap -caplet http-ui -iface wlan0 -debug

  • Caplet code you are using or the interactive session commands.
    http-ui caplet

  • Full debug output while reproducing the issue ( bettercap -debug ... ).
    wlan0 » [16:21:53] [sys.log] [err] Parameter health.battcurrent not valid: '-0.01' does not match rule '^[\d]+(.\d+)?$'.

Steps to Reproduce

See above

Expected behavior:
Negative number gets assigned to the float/decimal parameter.

Actual behavior:
Reg exp validation error for negative float/decimal parameter.

--

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant