* No space after ampersand escaped characters in XML https://github.com/clicon/clixon/issues/52
* Thanks @SCadilhac
This commit is contained in:
parent
f273f52148
commit
7450eae046
5 changed files with 17 additions and 15 deletions
|
|
@ -78,6 +78,8 @@
|
||||||
* Added command-line option `-t <timeout>` for clixon_netconf - quit after max time.
|
* Added command-line option `-t <timeout>` for clixon_netconf - quit after max time.
|
||||||
|
|
||||||
### Corrected Bugs
|
### Corrected Bugs
|
||||||
|
* No space after ampersand escaped characters in XML https://github.com/clicon/clixon/issues/52
|
||||||
|
* Thanks @SCadilhac
|
||||||
* Single quotes for XML attributes https://github.com/clicon/clixon/issues/51
|
* Single quotes for XML attributes https://github.com/clicon/clixon/issues/51
|
||||||
* Thanks @SCadilhac
|
* Thanks @SCadilhac
|
||||||
* Fixed https://github.com/clicon/clixon/issues/46 Issue with empty values in leaf-list
|
* Fixed https://github.com/clicon/clixon/issues/46 Issue with empty values in leaf-list
|
||||||
|
|
|
||||||
|
|
@ -356,7 +356,7 @@ xml_chardata_encode(char **escp,
|
||||||
else
|
else
|
||||||
switch (str[i]){
|
switch (str[i]){
|
||||||
case '&':
|
case '&':
|
||||||
len += strlen("& ");
|
len += strlen("&");
|
||||||
break;
|
break;
|
||||||
case '<':
|
case '<':
|
||||||
if (strncmp(&str[i], "<![CDATA[", strlen("<![CDATA[")) == 0){
|
if (strncmp(&str[i], "<![CDATA[", strlen("<![CDATA[")) == 0){
|
||||||
|
|
@ -364,10 +364,10 @@ xml_chardata_encode(char **escp,
|
||||||
cdata++;
|
cdata++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
len += strlen("< ");
|
len += strlen("<");
|
||||||
break;
|
break;
|
||||||
case '>':
|
case '>':
|
||||||
len += strlen("> ");
|
len += strlen(">");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
len++;
|
len++;
|
||||||
|
|
@ -395,7 +395,7 @@ xml_chardata_encode(char **escp,
|
||||||
else
|
else
|
||||||
switch (str[i]){
|
switch (str[i]){
|
||||||
case '&':
|
case '&':
|
||||||
if ((l=snprintf(&esc[j], 7, "& ")) < 0){
|
if ((l=snprintf(&esc[j], 6, "&")) < 0){
|
||||||
clicon_err(OE_UNIX, errno, "snprintf");
|
clicon_err(OE_UNIX, errno, "snprintf");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
@ -407,14 +407,14 @@ xml_chardata_encode(char **escp,
|
||||||
cdata++;
|
cdata++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((l=snprintf(&esc[j], 6, "< ")) < 0){
|
if ((l=snprintf(&esc[j], 5, "<")) < 0){
|
||||||
clicon_err(OE_UNIX, errno, "snprintf");
|
clicon_err(OE_UNIX, errno, "snprintf");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
j += l;
|
j += l;
|
||||||
break;
|
break;
|
||||||
case '>':
|
case '>':
|
||||||
if ((l=snprintf(&esc[j], 6, "> ")) < 0){
|
if ((l=snprintf(&esc[j], 5, ">")) < 0){
|
||||||
clicon_err(OE_UNIX, errno, "snprintf");
|
clicon_err(OE_UNIX, errno, "snprintf");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,11 +113,11 @@ int clixon_xml_parsewrap(void)
|
||||||
<STATEA>. { clixon_xml_parselval.string = yytext; return CHARDATA; /*XXX:optimize*/}
|
<STATEA>. { clixon_xml_parselval.string = yytext; return CHARDATA; /*XXX:optimize*/}
|
||||||
|
|
||||||
/* @see xml_chardata_encode */
|
/* @see xml_chardata_encode */
|
||||||
<AMPERSAND>"amp; " { BEGIN(_YA->ya_lex_state); clixon_xml_parselval.string = "&"; return CHARDATA;}
|
<AMPERSAND>"amp;" { BEGIN(_YA->ya_lex_state); clixon_xml_parselval.string = "&"; return CHARDATA;}
|
||||||
<AMPERSAND>"lt; " { BEGIN(_YA->ya_lex_state); clixon_xml_parselval.string = "<"; return CHARDATA;}
|
<AMPERSAND>"lt;" { BEGIN(_YA->ya_lex_state); clixon_xml_parselval.string = "<"; return CHARDATA;}
|
||||||
<AMPERSAND>"gt; " { BEGIN(_YA->ya_lex_state); clixon_xml_parselval.string = ">"; return CHARDATA;}
|
<AMPERSAND>"gt;" { BEGIN(_YA->ya_lex_state); clixon_xml_parselval.string = ">"; return CHARDATA;}
|
||||||
<AMPERSAND>"apos; " { BEGIN(_YA->ya_lex_state); clixon_xml_parselval.string = "'"; return CHARDATA;}
|
<AMPERSAND>"apos;" { BEGIN(_YA->ya_lex_state); clixon_xml_parselval.string = "'"; return CHARDATA;}
|
||||||
<AMPERSAND>"quot; " { BEGIN(_YA->ya_lex_state); clixon_xml_parselval.string = "\""; return CHARDATA;}
|
<AMPERSAND>"quot;" { BEGIN(_YA->ya_lex_state); clixon_xml_parselval.string = "\""; return CHARDATA;}
|
||||||
|
|
||||||
<CDATA>. { clixon_xml_parselval.string = yytext; return CHARDATA;}
|
<CDATA>. { clixon_xml_parselval.string = yytext; return CHARDATA;}
|
||||||
<CDATA>\n { clixon_xml_parselval.string = yytext;_YA->ya_linenum++; return (CHARDATA);}
|
<CDATA>\n { clixon_xml_parselval.string = yytext;_YA->ya_linenum++; return (CHARDATA);}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ if [ $? -ne 0 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "netconf hello"
|
new "netconf hello"
|
||||||
expecteof "$clixon_netconf -f $cfg -y $fyang" 0 '<rpc message-id="101"><get-config><source><candidate/></source></get-config></rpc>]]>]]>' '^<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><capabilities><capability>urn:ietf:params:netconf:base:1.0</capability><capability>urn:ietf:params:netconf:capability:yang-library:1.0?revision=2016-06-21& module-set-id=42</capability><capability>urn:ietf:params:netconf:capability:candidate:1:0</capability><capability>urn:ietf:params:netconf:capability:validate:1.1</capability><capability>urn:ietf:params:netconf:capability:startup:1.0</capability><capability>urn:ietf:params:netconf:capability:xpath:1.0</capability><capability>urn:ietf:params:netconf:capability:notification:1.0</capability></capabilities><session-id>[0-9]*</session-id></hello>]]>]]><rpc-reply message-id="101"><data/></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -f $cfg -y $fyang" 0 '<rpc message-id="101"><get-config><source><candidate/></source></get-config></rpc>]]>]]>' '^<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><capabilities><capability>urn:ietf:params:netconf:base:1.0</capability><capability>urn:ietf:params:netconf:capability:yang-library:1.0?revision=2016-06-21&module-set-id=42</capability><capability>urn:ietf:params:netconf:capability:candidate:1:0</capability><capability>urn:ietf:params:netconf:capability:validate:1.1</capability><capability>urn:ietf:params:netconf:capability:startup:1.0</capability><capability>urn:ietf:params:netconf:capability:xpath:1.0</capability><capability>urn:ietf:params:netconf:capability:notification:1.0</capability></capabilities><session-id>[0-9]*</session-id></hello>]]>]]><rpc-reply message-id="101"><data/></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "netconf get-config double quotes"
|
new "netconf get-config double quotes"
|
||||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><get-config><source><candidate/></source></get-config></rpc>]]>]]>' '^<rpc-reply message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><data/></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><get-config><source><candidate/></source></get-config></rpc>]]>]]>' '^<rpc-reply message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><data/></rpc-reply>]]>]]>$'
|
||||||
|
|
@ -183,10 +183,10 @@ new "netconf edit config merge"
|
||||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><edit-config><target><candidate/></target><config><interfaces><interface><name>eth2</name><type>ex:eth</type></interface></interfaces></config><default-operation>merge</default-operation></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><edit-config><target><candidate/></target><config><interfaces><interface><name>eth2</name><type>ex:eth</type></interface></interfaces></config><default-operation>merge</default-operation></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
new "netconf edit ampersand encoding(<&): name:'eth&' type:'t<>'"
|
new "netconf edit ampersand encoding(<&): name:'eth&' type:'t<>'"
|
||||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><edit-config><target><candidate/></target><config><interfaces><interface><name>eth& </name><type>t< > </type></interface></interfaces></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><edit-config><target><candidate/></target><config><interfaces><interface><name>eth&</name><type>t<></type></interface></interfaces></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
new "netconf get replaced config"
|
new "netconf get replaced config"
|
||||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply><data><interfaces><interface><name>eth& </name><type>t< > </type><enabled>true</enabled></interface><interface><name>eth1</name><type>ex:eth</type><enabled>true</enabled></interface><interface><name>eth2</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply><data><interfaces><interface><name>eth&</name><type>t<></type><enabled>true</enabled></interface><interface><name>eth1</name><type>ex:eth</type><enabled>true</enabled></interface><interface><name>eth2</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
new "cli show configuration eth& - encoding tests"
|
new "cli show configuration eth& - encoding tests"
|
||||||
expectfn "$clixon_cli -1 -f $cfg -y $fyang show conf cli" 0 "interfaces interface eth& type t<>
|
expectfn "$clixon_cli -1 -f $cfg -y $fyang show conf cli" 0 "interfaces interface eth& type t<>
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ new "xml encode <>&"
|
||||||
expecteof "$PROG" 0 "$XML" "^$XML$"
|
expecteof "$PROG" 0 "$XML" "^$XML$"
|
||||||
|
|
||||||
XML=$(cat <<EOF
|
XML=$(cat <<EOF
|
||||||
<message>To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character ' may be represented as ' and the double-quote character as " </message>
|
<message>To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character ' may be represented as ' and the double-quote character as "</message>
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
new "xml optional encode single and double quote"
|
new "xml optional encode single and double quote"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue