Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
git-svn-demo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
raila
git-svn-demo
Commits
a69e6b4b
Commit
a69e6b4b
authored
16 years ago
by
raila
Browse files
Options
Downloads
Patches
Plain Diff
Allow trailing slashes in --proto_path mappings.
Patch by Kevin Ko <kevin.s.ko@gmail.com>.
parent
9b943b25
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CONTRIBUTORS.txt
+3
-0
3 additions, 0 deletions
CONTRIBUTORS.txt
src/google/protobuf/compiler/importer.cc
+9
-1
9 additions, 1 deletion
src/google/protobuf/compiler/importer.cc
src/google/protobuf/compiler/importer_unittest.cc
+7
-0
7 additions, 0 deletions
src/google/protobuf/compiler/importer_unittest.cc
with
19 additions
and
1 deletion
CONTRIBUTORS.txt
+
3
−
0
View file @
a69e6b4b
...
@@ -33,3 +33,6 @@ Documentation:
...
@@ -33,3 +33,6 @@ Documentation:
Maven packaging:
Maven packaging:
Gregory Kick <gak@google.com>
Gregory Kick <gak@google.com>
Non-Google patch contributors:
Kevin Ko <kevin.s.ko@gmail.com>
This diff is collapsed.
Click to expand it.
src/google/protobuf/compiler/importer.cc
+
9
−
1
View file @
a69e6b4b
...
@@ -280,10 +280,18 @@ static bool ApplyMapping(const string& filename,
...
@@ -280,10 +280,18 @@ static bool ApplyMapping(const string& filename,
// Not an exact match. Is the next character a '/'? Otherwise,
// Not an exact match. Is the next character a '/'? Otherwise,
// this isn't actually a match at all. E.g. the prefix "foo/bar"
// this isn't actually a match at all. E.g. the prefix "foo/bar"
// does not match the filename "foo/barbaz".
// does not match the filename "foo/barbaz".
int
after_prefix_start
=
-
1
;
if
(
filename
[
old_prefix
.
size
()]
==
'/'
)
{
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
// Yep. So the prefixes are directories and the filename is a file
// inside them.
// inside them.
string
after_prefix
=
filename
.
substr
(
old
_prefix
.
size
()
+
1
);
string
after_prefix
=
filename
.
substr
(
after
_prefix
_start
);
if
(
ContainsParentReference
(
after_prefix
))
{
if
(
ContainsParentReference
(
after_prefix
))
{
// We do not allow the file name to use "..".
// We do not allow the file name to use "..".
return
false
;
return
false
;
...
...
This diff is collapsed.
Click to expand it.
src/google/protobuf/compiler/importer_unittest.cc
+
7
−
0
View file @
a69e6b4b
...
@@ -492,6 +492,7 @@ TEST_F(DiskSourceTreeTest, DiskFileToVirtualFileCanonicalization) {
...
@@ -492,6 +492,7 @@ TEST_F(DiskSourceTreeTest, DiskFileToVirtualFileCanonicalization) {
source_tree_
.
MapPath
(
"dir3"
,
"./foo/bar/."
);
source_tree_
.
MapPath
(
"dir3"
,
"./foo/bar/."
);
source_tree_
.
MapPath
(
"dir4"
,
"."
);
source_tree_
.
MapPath
(
"dir4"
,
"."
);
source_tree_
.
MapPath
(
""
,
"/qux"
);
source_tree_
.
MapPath
(
""
,
"/qux"
);
source_tree_
.
MapPath
(
"dir5"
,
"/quux/"
);
string
virtual_file
;
string
virtual_file
;
string
shadowing_disk_file
;
string
shadowing_disk_file
;
...
@@ -530,6 +531,12 @@ TEST_F(DiskSourceTreeTest, DiskFileToVirtualFileCanonicalization) {
...
@@ -530,6 +531,12 @@ TEST_F(DiskSourceTreeTest, DiskFileToVirtualFileCanonicalization) {
source_tree_
.
DiskFileToVirtualFile
(
source_tree_
.
DiskFileToVirtualFile
(
"/qux/baz"
,
&
virtual_file
,
&
shadowing_disk_file
));
"/qux/baz"
,
&
virtual_file
,
&
shadowing_disk_file
));
EXPECT_EQ
(
"baz"
,
virtual_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
}
// namespace
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment