Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
566dd8ce
Commit
566dd8ce
authored
Sep 30, 2013
by
Linquize
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Config subsection name should allow to have ']' and '\\' should allow to escape any characters
parent
e6a1d9a2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
26 deletions
+15
-26
src/config_file.c
+15
-26
No files found.
src/config_file.c
View file @
566dd8ce
...
@@ -712,7 +712,6 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
...
@@ -712,7 +712,6 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
int
c
,
rpos
;
int
c
,
rpos
;
char
*
first_quote
,
*
last_quote
;
char
*
first_quote
,
*
last_quote
;
git_buf
buf
=
GIT_BUF_INIT
;
git_buf
buf
=
GIT_BUF_INIT
;
int
quote_marks
;
/*
/*
* base_name is what came before the space. We should be at the
* base_name is what came before the space. We should be at the
* first quotation mark, except for now, line isn't being kept in
* first quotation mark, except for now, line isn't being kept in
...
@@ -731,21 +730,15 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
...
@@ -731,21 +730,15 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
git_buf_printf
(
&
buf
,
"%s."
,
base_name
);
git_buf_printf
(
&
buf
,
"%s."
,
base_name
);
rpos
=
0
;
rpos
=
0
;
quote_marks
=
0
;
line
=
first_quote
;
line
=
first_quote
;
c
=
line
[
rpos
++
];
c
=
line
[
++
rpos
];
/*
/*
* At the end of each iteration, whatever is stored in c will be
* At the end of each iteration, whatever is stored in c will be
* added to the string. In case of error, jump to out
* added to the string. In case of error, jump to out
*/
*/
do
{
do
{
if
(
quote_marks
==
2
)
{
set_parse_error
(
reader
,
rpos
,
"Unexpected text after closing quotes"
);
git_buf_free
(
&
buf
);
return
-
1
;
}
switch
(
c
)
{
switch
(
c
)
{
case
0
:
case
0
:
...
@@ -754,25 +747,13 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
...
@@ -754,25 +747,13 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
return
-
1
;
return
-
1
;
case
'"'
:
case
'"'
:
++
quote_marks
;
goto
end_parse
;
continue
;
case
'\\'
:
c
=
line
[
rpos
++
];
switch
(
c
)
{
case
'"'
:
if
(
&
line
[
rpos
-
1
]
==
last_quote
)
{
set_parse_error
(
reader
,
0
,
"Missing closing quotation mark in section header"
);
git_buf_free
(
&
buf
);
return
-
1
;
}
case
'\\'
:
case
'\\'
:
break
;
c
=
line
[
++
rpos
]
;
default
:
if
(
c
==
0
)
{
set_parse_error
(
reader
,
rpos
,
"Un
supported escape sequence
"
);
set_parse_error
(
reader
,
rpos
,
"Un
expected end-of-line in section header
"
);
git_buf_free
(
&
buf
);
git_buf_free
(
&
buf
);
return
-
1
;
return
-
1
;
}
}
...
@@ -782,7 +763,15 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
...
@@ -782,7 +763,15 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
}
}
git_buf_putc
(
&
buf
,
(
char
)
c
);
git_buf_putc
(
&
buf
,
(
char
)
c
);
}
while
((
c
=
line
[
rpos
++
])
!=
']'
);
c
=
line
[
++
rpos
];
}
while
(
line
+
rpos
<
last_quote
);
end_parse
:
if
(
line
[
rpos
]
!=
'"'
||
line
[
rpos
+
1
]
!=
']'
)
{
set_parse_error
(
reader
,
rpos
,
"Unexpected text after closing quotes"
);
git_buf_free
(
&
buf
);
return
-
1
;
}
*
section_name
=
git_buf_detach
(
&
buf
);
*
section_name
=
git_buf_detach
(
&
buf
);
return
0
;
return
0
;
...
@@ -800,7 +789,7 @@ static int parse_section_header(struct reader *reader, char **section_out)
...
@@ -800,7 +789,7 @@ static int parse_section_header(struct reader *reader, char **section_out)
return
-
1
;
return
-
1
;
/* find the end of the variable's name */
/* find the end of the variable's name */
name_end
=
strchr
(
line
,
']'
);
name_end
=
str
r
chr
(
line
,
']'
);
if
(
name_end
==
NULL
)
{
if
(
name_end
==
NULL
)
{
git__free
(
line
);
git__free
(
line
);
set_parse_error
(
reader
,
0
,
"Missing ']' in section header"
);
set_parse_error
(
reader
,
0
,
"Missing ']' in section header"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment