diff options
| author | Mike Frysinger <vapier@google.com> | 2021-04-29 23:15:31 -0400 |
|---|---|---|
| committer | Mike Frysinger <vapier@google.com> | 2021-04-30 05:54:11 +0000 |
| commit | f69c7ee3187eded54e83d2524fea423706380766 (patch) | |
| tree | e78c5ba603ef7e7975a2df87071a8afa1910dd5a /manifest_xml.py | |
| parent | aabf79d3f0736af3bbe9f2e830df6165e06b6ef6 (diff) | |
| download | git-repo-f69c7ee3187eded54e83d2524fea423706380766.tar.gz | |
manifest_xml: ban use of newlines in paths
There should be no valid use of these anywhere, so just ban them
to make things easier for people.
Bug: https://crbug.com/gerrit/14156
Bug: https://crbug.com/gerrit/14200
Change-Id: I8d2cf988c510c98194c43a329a2b9bf313a3f0a8
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/304662
Reviewed-by: Raman Tenneti <rtenneti@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'manifest_xml.py')
| -rw-r--r-- | manifest_xml.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index 0c2b45e5..64b7fb4e 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
| @@ -1199,6 +1199,8 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 1199 | if '~' in path: | 1199 | if '~' in path: |
| 1200 | return '~ not allowed (due to 8.3 filenames on Windows filesystems)' | 1200 | return '~ not allowed (due to 8.3 filenames on Windows filesystems)' |
| 1201 | 1201 | ||
| 1202 | path_codepoints = set(path) | ||
| 1203 | |||
| 1202 | # Some filesystems (like Apple's HFS+) try to normalize Unicode codepoints | 1204 | # Some filesystems (like Apple's HFS+) try to normalize Unicode codepoints |
| 1203 | # which means there are alternative names for ".git". Reject paths with | 1205 | # which means there are alternative names for ".git". Reject paths with |
| 1204 | # these in it as there shouldn't be any reasonable need for them here. | 1206 | # these in it as there shouldn't be any reasonable need for them here. |
| @@ -1222,10 +1224,17 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 1222 | u'\u206F', # NOMINAL DIGIT SHAPES | 1224 | u'\u206F', # NOMINAL DIGIT SHAPES |
| 1223 | u'\uFEFF', # ZERO WIDTH NO-BREAK SPACE | 1225 | u'\uFEFF', # ZERO WIDTH NO-BREAK SPACE |
| 1224 | } | 1226 | } |
| 1225 | if BAD_CODEPOINTS & set(path): | 1227 | if BAD_CODEPOINTS & path_codepoints: |
| 1226 | # This message is more expansive than reality, but should be fine. | 1228 | # This message is more expansive than reality, but should be fine. |
| 1227 | return 'Unicode combining characters not allowed' | 1229 | return 'Unicode combining characters not allowed' |
| 1228 | 1230 | ||
| 1231 | # Reject newlines as there shouldn't be any legitmate use for them, they'll | ||
| 1232 | # be confusing to users, and they can easily break tools that expect to be | ||
| 1233 | # able to iterate over newline delimited lists. This even applies to our | ||
| 1234 | # own code like .repo/project.list. | ||
| 1235 | if {'\r', '\n'} & path_codepoints: | ||
| 1236 | return 'Newlines not allowed' | ||
| 1237 | |||
| 1229 | # Assume paths might be used on case-insensitive filesystems. | 1238 | # Assume paths might be used on case-insensitive filesystems. |
| 1230 | path = path.lower() | 1239 | path = path.lower() |
| 1231 | 1240 | ||
