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

lnms config:set breaks regexp by escaping \ to \\ #14088

Open
manonfgoo opened this issue Jul 4, 2022 · 2 comments
Open

lnms config:set breaks regexp by escaping \ to \\ #14088

manonfgoo opened this issue Jul 4, 2022 · 2 comments

Comments

@manonfgoo
Copy link
Contributor

manonfgoo commented Jul 4, 2022

The problem

If I enter a regexp with \ it is saved as \\

expected:

user@host$ lnms config:set   bad_if_regexp.+ "/vlan\s\d+/"
user@host$  lnms config:get   bad_if_regexp
 [
    "/^ng[0-9]+$/",
    "/^sl[0-9]/",
    "/vlan\s\d+/"
]

Observed:

user@host$ lnms config:set   bad_if_regexp.+ "/vlan\s\d+/"
user@host$  lnms config:get   bad_if_regexp
 [
    "/^ng[0-9]+$/",
    "/^sl[0-9]/",
    "/vlan\\s\\d+/"
]

Output of ./validate.php

ConfigurationOk
DatabaseOk
DependenciesOk
DiskOk
DistributedpollerOk
MailOk
PhpOk
ProgramsWarning
Warning: IPv6 is disabled on your server, you will not be able to add IPv6 devices.
PythonOk
RrdOk
RrdcheckOk
SystemOk
UpdatesWarning
Warning: Non-git install, updates are manual or from package
UserOK

What was the last working version of LibreNMS?

No response

Anything in the logs that might be useful for us?

No response

@manonfgoo manonfgoo changed the title lnms config:set breraks regexp by escaping \ to \\ lnms config:set breaks regexp by escaping \ to \\ Jul 4, 2022
@murrant
Copy link
Member

murrant commented Jul 15, 2022

This is actually on the display side, it is stored in the database correctly.

Try lnms config:get bad_if_regexp.2

@murrant
Copy link
Member

murrant commented Jul 15, 2022

Hmm, I don't think we want to change that. If we stripslashes() on the json output, it won't be valid json to edit and set back in the database.

It might make sense to have a non-json display.

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

No branches or pull requests

2 participants