Page MenuHomePhabricator

<regex> constraints in XML are partially broken
Closed, ResolvedPublicBUG

Description

The backslash \ symbol in <regex> definitions inside XML templates will be ignored during comparison, this makes unusable any regex which contains it, like:

\d
\b
\w
\\

The problem exists because all regex are converting into node.def as-is. And later, configuration parser considers \ as an escape symbol. So, we need to add escaping of \ before saving it to node.def.

Example:
XML: <regex>^\d\w123$</regex>
node.def: syntax:expression: exec "${vyos_libexec_dir}/validate-value.py --regex \'^\d\w123$\' --value \'$VAR(@)\'"; "Invalid value"
Scripts arguments: ['/usr/libexec/vyos/validate-value.py', '--regex', '^dw123$', '--value', 'test']

Details

Difficulty level
Easy (less than an hour)
Version
1.2-rolling-201910250117
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Perfectly compatible

Event Timeline

zsdc created this task.Oct 25 2019, 8:25 PM
pasik added a subscriber: pasik.Oct 27 2019, 5:41 PM
syncer changed the task status from Open to Backport candidate.Nov 16 2019, 10:53 PM
syncer assigned this task to jestabro.
syncer triaged this task as Low priority.
syncer moved this task from Need Triage to Finished on the VyOS 1.3 Equuleus board.
syncer moved this task from Needs Triage to Backlog on the VyOS 1.2 Crux (VyOS 1.2.4) board.
jestabro closed this task as Resolved.Nov 22 2019, 2:05 PM