Stop PathForModuleSrc from validating the paths unnecessarily
PathForModuleSrc calls validatePath in order to convert the supplied path components into a single path. Unfortunately, that corrupts a fully qualified module name. So, when given "//namespace:module" it treats it as a path and replaces "//" with "/". That replacement is done by a call to filepath.Join(). This change simply concatenates the path components together textually, using the path separator, to avoid the corruption. That ensures that a fully qualified module name is preserved and processed properly. If the path components do not contain a module name then expandOneSrcPath will call pathForModuleSrc which validates the path so it does not open up a way to create an invalid path as the validation was unnecessary anyway. Bug: 193228441 Test: m nothing Change-Id: I0bb66feac182b77ce96c8d5d5f17e28ea28d75ba
This commit is contained in:
@@ -1268,10 +1268,11 @@ var _ resPathProvider = SourcePath{}
|
||||
// PathForModuleSrc returns a Path representing the paths... under the
|
||||
// module's local source directory.
|
||||
func PathForModuleSrc(ctx ModuleMissingDepsPathContext, pathComponents ...string) Path {
|
||||
p, err := validatePath(pathComponents...)
|
||||
if err != nil {
|
||||
reportPathError(ctx, err)
|
||||
}
|
||||
// Just join the components textually just to make sure that it does not corrupt a fully qualified
|
||||
// module reference, e.g. if the pathComponents is "://other:foo" then using filepath.Join() or
|
||||
// validatePath() will corrupt it, e.g. replace "//" with "/". If the path is not a module
|
||||
// reference then it will be validated by expandOneSrcPath anyway when it calls expandOneSrcPath.
|
||||
p := strings.Join(pathComponents, string(filepath.Separator))
|
||||
paths, err := expandOneSrcPath(ctx, p, nil)
|
||||
if err != nil {
|
||||
if depErr, ok := err.(missingDependencyError); ok {
|
||||
|
Reference in New Issue
Block a user