Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
e773b432
Commit
e773b432
authored
Jul 16, 2008
by
temporal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow trailing slashes in --proto_path mappings.
Patch by Kevin Ko <kevin.s.ko@gmail.com>.
parent
928ebb6b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
CONTRIBUTORS.txt
CONTRIBUTORS.txt
+3
-0
importer.cc
src/google/protobuf/compiler/importer.cc
+9
-1
importer_unittest.cc
src/google/protobuf/compiler/importer_unittest.cc
+7
-0
No files found.
CONTRIBUTORS.txt
View file @
e773b432
...
...
@@ -33,3 +33,6 @@ Documentation:
Maven packaging:
Gregory Kick <gak@google.com>
Non-Google patch contributors:
Kevin Ko <kevin.s.ko@gmail.com>
src/google/protobuf/compiler/importer.cc
View file @
e773b432
...
...
@@ -280,10 +280,18 @@ static bool ApplyMapping(const string& filename,
// Not an exact match. Is the next character a '/'? Otherwise,
// this isn't actually a match at all. E.g. the prefix "foo/bar"
// does not match the filename "foo/barbaz".
int
after_prefix_start
=
-
1
;
if
(
filename
[
old_prefix
.
size
()]
==
'/'
)
{
after_prefix_start
=
old_prefix
.
size
()
+
1
;
}
else
if
(
filename
[
old_prefix
.
size
()
-
1
]
==
'/'
)
{
// old_prefix is never empty, and canonicalized paths never have
// consecutive '/' characters.
after_prefix_start
=
old_prefix
.
size
();
}
if
(
after_prefix_start
!=
-
1
)
{
// Yep. So the prefixes are directories and the filename is a file
// inside them.
string
after_prefix
=
filename
.
substr
(
old_prefix
.
size
()
+
1
);
string
after_prefix
=
filename
.
substr
(
after_prefix_start
);
if
(
ContainsParentReference
(
after_prefix
))
{
// We do not allow the file name to use "..".
return
false
;
...
...
src/google/protobuf/compiler/importer_unittest.cc
View file @
e773b432
...
...
@@ -492,6 +492,7 @@ TEST_F(DiskSourceTreeTest, DiskFileToVirtualFileCanonicalization) {
source_tree_
.
MapPath
(
"dir3"
,
"./foo/bar/."
);
source_tree_
.
MapPath
(
"dir4"
,
"."
);
source_tree_
.
MapPath
(
""
,
"/qux"
);
source_tree_
.
MapPath
(
"dir5"
,
"/quux/"
);
string
virtual_file
;
string
shadowing_disk_file
;
...
...
@@ -530,6 +531,12 @@ TEST_F(DiskSourceTreeTest, DiskFileToVirtualFileCanonicalization) {
source_tree_
.
DiskFileToVirtualFile
(
"/qux/baz"
,
&
virtual_file
,
&
shadowing_disk_file
));
EXPECT_EQ
(
"baz"
,
virtual_file
);
// "/quux/bar" is under "/quux".
EXPECT_EQ
(
DiskSourceTree
::
CANNOT_OPEN
,
source_tree_
.
DiskFileToVirtualFile
(
"/quux/bar"
,
&
virtual_file
,
&
shadowing_disk_file
));
EXPECT_EQ
(
"dir5/bar"
,
virtual_file
);
}
}
// namespace
...
...
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