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
c7d4904c
Commit
c7d4904c
authored
Aug 07, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1769 from ethomson/configparse
Parse config headers with quoted quotes
parents
c5780abb
2d9f5b9f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
5 deletions
+27
-5
src/config_file.c
+11
-0
tests-clar/config/read.c
+16
-5
No files found.
src/config_file.c
View file @
c7d4904c
...
...
@@ -792,6 +792,11 @@ static int parse_section_header_ext(diskfile_backend *cfg, const char *line, con
}
switch
(
c
)
{
case
0
:
set_parse_error
(
cfg
,
0
,
"Unexpected end-of-line in section header"
);
git_buf_free
(
&
buf
);
return
-
1
;
case
'"'
:
++
quote_marks
;
continue
;
...
...
@@ -801,6 +806,12 @@ static int parse_section_header_ext(diskfile_backend *cfg, const char *line, con
switch
(
c
)
{
case
'"'
:
if
(
&
line
[
rpos
-
1
]
==
last_quote
)
{
set_parse_error
(
cfg
,
0
,
"Missing closing quotation mark in section header"
);
git_buf_free
(
&
buf
);
return
-
1
;
}
case
'\\'
:
break
;
...
...
tests-clar/config/read.c
View file @
c7d4904c
...
...
@@ -431,10 +431,10 @@ void test_config_read__simple_read_from_specific_level(void)
git_config_free
(
cfg
);
}
static
void
clean_
empty
_config
(
void
*
unused
)
static
void
clean_
test
_config
(
void
*
unused
)
{
GIT_UNUSED
(
unused
);
cl_fixture_cleanup
(
"./
empty
"
);
cl_fixture_cleanup
(
"./
testconfig
"
);
}
void
test_config_read__can_load_and_parse_an_empty_config_file
(
void
)
...
...
@@ -442,10 +442,21 @@ void test_config_read__can_load_and_parse_an_empty_config_file(void)
git_config
*
cfg
;
int
i
;
cl_set_cleanup
(
&
clean_
empty
_config
,
NULL
);
cl_git_mkfile
(
"./
empty
"
,
""
);
cl_git_pass
(
git_config_open_ondisk
(
&
cfg
,
"./
empty
"
));
cl_set_cleanup
(
&
clean_
test
_config
,
NULL
);
cl_git_mkfile
(
"./
testconfig
"
,
""
);
cl_git_pass
(
git_config_open_ondisk
(
&
cfg
,
"./
testconfig
"
));
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_config_get_int32
(
&
i
,
cfg
,
"nope.neither"
));
git_config_free
(
cfg
);
}
void
test_config_read__corrupt_header
(
void
)
{
git_config
*
cfg
;
cl_set_cleanup
(
&
clean_test_config
,
NULL
);
cl_git_mkfile
(
"./testconfig"
,
"[sneaky ]
\"
quoted closing quote mark
\\\"
"
);
cl_git_fail
(
git_config_open_ondisk
(
&
cfg
,
"./testconfig"
));
git_config_free
(
cfg
);
}
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