* Fixed: Autocli YANG patterns including " were not properly escaped: \"
This commit is contained in:
parent
77b4468eb3
commit
95f6fe8b1a
4 changed files with 23 additions and 17 deletions
|
|
@ -106,6 +106,7 @@ Users may have to change how they access the system
|
|||
|
||||
### Corrected Bugs
|
||||
|
||||
* Fixed: Autocli YANG patterns including `"` were not properly escaped: `\"`
|
||||
* Ensure auto-cli can be run with `CLICON_CLI_VARONLY=1`
|
||||
* Strip constants in cli_dbxml
|
||||
* rpc_callback_call(): Check if nrp parameter is NULL to avoid SEGV
|
||||
|
|
|
|||
|
|
@ -332,6 +332,7 @@ yang2cli_var_range(yang_stmt *ys,
|
|||
* @param[in] patterns Cvec of regexp patterns
|
||||
* @param[out] cb Buffer where cligen code is written
|
||||
* @see cv_validate_pattern for netconf validate code
|
||||
* @note for cligen, need to escape " -> \"
|
||||
*/
|
||||
static int
|
||||
yang2cli_var_pattern(clicon_handle h,
|
||||
|
|
@ -343,32 +344,43 @@ yang2cli_var_pattern(clicon_handle h,
|
|||
cg_var *cvp;
|
||||
char *pattern;
|
||||
int invert;
|
||||
char *posix;
|
||||
char *posix = NULL;
|
||||
int i;
|
||||
|
||||
mode = clicon_yang_regexp(h);
|
||||
cvp = NULL; /* Loop over compiled regexps */
|
||||
while ((cvp = cvec_each(patterns, cvp)) != NULL){
|
||||
pattern = cv_string_get(cvp);
|
||||
invert = cv_flag(cvp, V_INVERT);
|
||||
cprintf(cb, " regexp:%s\"", invert?"!":"");
|
||||
if (mode == REGEXP_POSIX){
|
||||
posix = NULL;
|
||||
if (regexp_xsd2posix(pattern, &posix) < 0)
|
||||
goto done;
|
||||
cprintf(cb, " regexp:%s\"%s\"",
|
||||
invert?"!":"",
|
||||
posix);
|
||||
for (i=0; i<strlen(posix); i++){
|
||||
if (posix[i] == '\"')
|
||||
cbuf_append(cb, '\\');
|
||||
cbuf_append(cb, posix[i]);
|
||||
}
|
||||
if (posix){
|
||||
free(posix);
|
||||
posix = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
cprintf(cb, " regexp:%s\"%s\"",
|
||||
invert?"!":"",
|
||||
pattern);
|
||||
else{
|
||||
for (i=0; i<strlen(pattern); i++){
|
||||
if (pattern[i] == '\"')
|
||||
cbuf_append(cb, '\\');
|
||||
cbuf_append(cb, pattern[i]);
|
||||
}
|
||||
}
|
||||
cprintf(cb, "\"");
|
||||
}
|
||||
retval = 0;
|
||||
done:
|
||||
if (posix)
|
||||
free(posix);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
</restconf>
|
||||
<autocli>
|
||||
<module-default>false</module-default>
|
||||
<list-keyword-default>kw-key</list-keyword-default>
|
||||
<list-keyword-default>kw-nokey</list-keyword-default>
|
||||
<treeref-state-default>false</treeref-state-default>
|
||||
<edit-mode-default>list container</edit-mode-default>
|
||||
<completion-default>true</completion-default>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ cat <<EOF > $cfg
|
|||
<rule>
|
||||
<name>openconfig1</name>
|
||||
<operation>enable</operation>
|
||||
<module-name>openconfig-bgp</module-name>
|
||||
<module-name>clixon-example</module-name>
|
||||
</rule>
|
||||
<rule>
|
||||
<name>openconfig2</name>
|
||||
|
|
@ -70,13 +70,6 @@ EOF
|
|||
# Example system
|
||||
cat <<EOF > $dir/startup_db
|
||||
<config>
|
||||
<bgp xmlns="http://openconfig.net/yang/bgp">
|
||||
<global>
|
||||
<config>
|
||||
<as>0</as> /* XXX */
|
||||
</config>
|
||||
</global>
|
||||
</bgp>
|
||||
<network-instances xmlns="http://openconfig.net/yang/network-instance">
|
||||
<network-instance>
|
||||
<name>default</name>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue