* Single quotes for XML attributes https://github.com/clicon/clixon/issues/51
* Thanks @SCadilhac
This commit is contained in:
parent
61869c8d44
commit
906763317b
5 changed files with 40 additions and 29 deletions
|
|
@ -94,6 +94,8 @@
|
||||||
* Added -l option for clixon_backend for directing syslog to stderr or stdout if running in foreground
|
* Added -l option for clixon_backend for directing syslog to stderr or stdout if running in foreground
|
||||||
|
|
||||||
### Corrected Bugs
|
### Corrected Bugs
|
||||||
|
* Single quotes for XML attributes https://github.com/clicon/clixon/issues/51
|
||||||
|
* 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
|
||||||
* Thanks achernavin22
|
* Thanks achernavin22
|
||||||
* Identity without any identityref:s caused SEGV
|
* Identity without any identityref:s caused SEGV
|
||||||
|
|
|
||||||
|
|
@ -89,17 +89,18 @@ int clixon_xml_parsewrap(void)
|
||||||
return NAME; /* rather be catch-all */
|
return NAME; /* rather be catch-all */
|
||||||
}
|
}
|
||||||
<START>[ \t]+ ;
|
<START>[ \t]+ ;
|
||||||
<START>\: return *clixon_xml_parsetext;
|
<START>\: return *clixon_xml_parsetext;
|
||||||
<START>\n { _YA->ya_linenum++;}
|
<START>\n { _YA->ya_linenum++;}
|
||||||
<START>"<?xml" { BEGIN(TEXTDECL); return BTEXT;}
|
<START>"<?xml" { BEGIN(TEXTDECL); return BTEXT;}
|
||||||
<START>"/>" { BEGIN(STATEA); return ESLASH; }
|
<START>"/>" { BEGIN(STATEA); return ESLASH; }
|
||||||
<START>"<!--" { BEGIN(CMNT); return BCOMMENT; }
|
<START>"<!--" { BEGIN(CMNT); return BCOMMENT; }
|
||||||
<START>"</" return BSLASH;
|
<START>"</" return BSLASH;
|
||||||
<START>[/=] return *clixon_xml_parsetext;
|
<START>[/=] return *clixon_xml_parsetext;
|
||||||
<START>\< return *clixon_xml_parsetext;
|
<START>\< return *clixon_xml_parsetext;
|
||||||
<START>\> { BEGIN(STATEA); return *clixon_xml_parsetext; }
|
<START>\> { BEGIN(STATEA); return *clixon_xml_parsetext; }
|
||||||
|
|
||||||
<START>\" { BEGIN(STR); return *clixon_xml_parsetext; }
|
<START>\" { _YA->ya_lex_state=START;BEGIN(STRDQ); return *clixon_xml_parsetext; }
|
||||||
|
<START>\' { _YA->ya_lex_state=START;BEGIN(STRSQ); return *clixon_xml_parsetext; }
|
||||||
<START>. { clixon_xml_parselval.string = yytext; return CHARDATA; /*XXX:optimize*/ }
|
<START>. { clixon_xml_parselval.string = yytext; return CHARDATA; /*XXX:optimize*/ }
|
||||||
|
|
||||||
<STATEA>"</" { BEGIN(START); return BSLASH; }
|
<STATEA>"</" { BEGIN(START); return BSLASH; }
|
||||||
|
|
@ -112,36 +113,33 @@ 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);}
|
||||||
<CDATA>"]]>" { BEGIN(_YA->ya_lex_state); clixon_xml_parselval.string = yytext; return CHARDATA;}
|
<CDATA>"]]>" { BEGIN(_YA->ya_lex_state); clixon_xml_parselval.string = yytext; return CHARDATA;}
|
||||||
|
|
||||||
<CMNT>"-->" { BEGIN(START); return ECOMMENT; }
|
<CMNT>"-->" { BEGIN(START); return ECOMMENT; }
|
||||||
<CMNT>\n _YA->ya_linenum++;
|
<CMNT>\n _YA->ya_linenum++;
|
||||||
<CMNT>.
|
<CMNT>.
|
||||||
<TEXTDECL>encoding return ENC;
|
<TEXTDECL>encoding return ENC;
|
||||||
<TEXTDECL>version return VER;
|
<TEXTDECL>version return VER;
|
||||||
<TEXTDECL>"=" return *clixon_xml_parsetext;
|
<TEXTDECL>"=" return *clixon_xml_parsetext;
|
||||||
<TEXTDECL>"?>" { BEGIN(START);return ETEXT;}
|
<TEXTDECL>"?>" { BEGIN(START);return ETEXT;}
|
||||||
<TEXTDECL>\" { BEGIN(STRDQ); return *clixon_xml_parsetext; }
|
<TEXTDECL>\" { _YA->ya_lex_state =TEXTDECL;BEGIN(STRDQ); return *clixon_xml_parsetext; }
|
||||||
<TEXTDECL>\' { BEGIN(STRSQ); return *clixon_xml_parsetext; }
|
<TEXTDECL>\' { _YA->ya_lex_state =TEXTDECL;BEGIN(STRSQ); return *clixon_xml_parsetext; }
|
||||||
|
|
||||||
<STR>[^\"]+ { clixon_xml_parselval.string = strdup(yytext); return CHARDATA; }
|
<STRDQ>1\.[0-9]+ { clixon_xml_parselval.string = strdup(yytext); return CHARDATA; }
|
||||||
<STR>\" { BEGIN(START); return *clixon_xml_parsetext; }
|
<STRDQ>[^\"]+ { clixon_xml_parselval.string = strdup(yytext); return CHARDATA; }
|
||||||
|
<STRDQ>\" { BEGIN(_YA->ya_lex_state); return *clixon_xml_parsetext; }
|
||||||
|
|
||||||
<STRDQ>1\.[0-9]+ { clixon_xml_parselval.string = strdup(yytext); return CHARDATA; }
|
<STRSQ>1\.[0-9]+ { clixon_xml_parselval.string = strdup(yytext); return CHARDATA; }
|
||||||
<STRDQ>[^\"]+ { clixon_xml_parselval.string = strdup(yytext); return CHARDATA; }
|
<STRSQ>[^\']+ { clixon_xml_parselval.string = strdup(yytext); return CHARDATA; }
|
||||||
<STRDQ>\" { BEGIN(TEXTDECL); return *clixon_xml_parsetext; }
|
<STRSQ>\' { BEGIN(_YA->ya_lex_state); return *clixon_xml_parsetext; }
|
||||||
|
|
||||||
<STRSQ>1\.[0-9]+ { clixon_xml_parselval.string = strdup(yytext); return CHARDATA; }
|
|
||||||
<STRSQ>[^\']+ { clixon_xml_parselval.string = strdup(yytext); return CHARDATA; }
|
|
||||||
<STRSQ>\' { BEGIN(TEXTDECL); return *clixon_xml_parsetext; }
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -401,6 +401,8 @@ attr : NAME '=' attvalue { if (xml_parse_attr(_YA, NULL, $1, $3)
|
||||||
|
|
||||||
attvalue : '\"' CHARDATA '\"' { $$=$2; /* $2 must be consumed */}
|
attvalue : '\"' CHARDATA '\"' { $$=$2; /* $2 must be consumed */}
|
||||||
| '\"' '\"' { $$=strdup(""); /* $2 must be consumed */}
|
| '\"' '\"' { $$=strdup(""); /* $2 must be consumed */}
|
||||||
|
| '\'' CHARDATA '\'' { $$=$2; /* $2 must be consumed */}
|
||||||
|
| '\'' '\'' { $$=strdup(""); /* $2 must be consumed */}
|
||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,11 @@ 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.1</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.1</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"
|
new "netconf get-config double quotes"
|
||||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '<rpc message-id="101"><get-config><source><candidate/></source></get-config></rpc>]]>]]>' '^<rpc-reply message-id="101"><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>]]>]]>$'
|
||||||
|
|
||||||
|
new "netconf get-config single 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>]]>]]>$'
|
||||||
|
|
||||||
new "Add subtree eth/0/0 using none which should not change anything"
|
new "Add subtree eth/0/0 using none which should not change anything"
|
||||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><edit-config><default-operation>none</default-operation><target><candidate/></target><config><interfaces><interface><name>eth/0/0</name></interface></interfaces></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><edit-config><default-operation>none</default-operation><target><candidate/></target><config><interfaces><interface><name>eth/0/0</name></interface></interfaces></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||||
|
|
|
||||||
|
|
@ -43,5 +43,11 @@ EOF
|
||||||
new "xml optional encode single and double quote"
|
new "xml optional encode single and double quote"
|
||||||
expecteof "$PROG" 0 "$XML" "^<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>$"
|
expecteof "$PROG" 0 "$XML" "^<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>$"
|
||||||
|
|
||||||
|
new "Double quotes for attributes"
|
||||||
|
expecteof "$PROG" 0 '<x a="t"/>' '^<x a="t"/>$'
|
||||||
|
|
||||||
|
new "Single quotes for attributes (returns double quotes but at least parses right)"
|
||||||
|
expecteof "$PROG" 0 "<x a='t'/>" '^<x a="t"/>$'
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue