Skip to content

Commit 7b9fd03

Browse files
PavolVicanrkrejci
authored andcommitted
parser yang BUGFIX reading backslash in double-qouted string
1 parent edab6c5 commit 7b9fd03

File tree

6 files changed

+1220
-1201
lines changed

6 files changed

+1220
-1201
lines changed

src/parser_yang.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,7 +2832,7 @@ read_indent(const char *input, int indent, int size, int in_index, int *out_inde
28322832
}
28332833

28342834
char *
2835-
yang_read_string(const char *input, char *output, int size, int offset, int indent, int version) {
2835+
yang_read_string(const char *input, char *output, int size, int offset, int indent) {
28362836
int i = 0, out_index = offset, space = 0;
28372837

28382838
while (i < size) {
@@ -2865,13 +2865,9 @@ yang_read_string(const char *input, char *output, int size, int offset, int inde
28652865
output[out_index] = '"';
28662866
++i;
28672867
} else {
2868-
if (version < 2) {
2869-
output[out_index] = input[i];
2870-
} else {
2871-
/* YANG 1.1 backslash must not be followed by any other character */
2872-
LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, input);
2873-
return NULL;
2874-
}
2868+
/* backslash must not be followed by any other character */
2869+
LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, input);
2870+
return NULL;
28752871
}
28762872
break;
28772873
default:

src/parser_yang.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct yang_type {
112112

113113
#include "parser_yang_bis.h"
114114

115-
char *yang_read_string(const char *input, char *output, int size, int offset, int indent, int version);
115+
char *yang_read_string(const char *input, char *output, int size, int offset, int indent);
116116

117117
int yang_read_common(struct lys_module *module,char *value, enum yytokentype type);
118118

src/parser_yang_bis.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,7 +3029,7 @@ YYLTYPE yylloc = yyloc_default;
30293029
LOGMEM;
30303030
YYABORT;
30313031
}
3032-
if (!(tmp = yang_read_string(yyget_text(scanner) + 1, s, yyget_leng(scanner) - 2, 0, yylloc.first_column, (trg) ? trg->version : 0))) {
3032+
if (!(tmp = yang_read_string(yyget_text(scanner) + 1, s, yyget_leng(scanner) - 2, 0, yylloc.first_column))) {
30333033
YYABORT;
30343034
}
30353035
s = tmp;
@@ -3062,7 +3062,7 @@ YYLTYPE yylloc = yyloc_default;
30623062
}
30633063
s = tmp;
30643064
if (yyget_text(scanner)[0] == '"') {
3065-
if (!(tmp = yang_read_string(yyget_text(scanner) + 1, s, length_tmp - 2, length_s, yylloc.first_column, (trg) ? trg->version : 0))) {
3065+
if (!(tmp = yang_read_string(yyget_text(scanner) + 1, s, length_tmp - 2, length_s, yylloc.first_column))) {
30663066
YYABORT;
30673067
}
30683068
s = tmp;
@@ -5425,7 +5425,7 @@ YYLTYPE yylloc = yyloc_default;
54255425
}
54265426
if ((yyvsp[-1].nodes).node.ptr_leaflist->dflt_size && (yyvsp[-1].nodes).node.ptr_leaflist->min) {
54275427
LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "min-elements", "leaf-list");
5428-
LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL,
5428+
LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL,
54295429
"The \"min-elements\" statement with non-zero value is forbidden on leaf-lists with the \"default\" statement.");
54305430
YYABORT;
54315431
}

0 commit comments

Comments
 (0)