You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Platform string to be of the form
<os>[(<osversion>)]|<arch>|<os>[(<OSVersion>)]/<arch>[/<variant>]
OSVersion is optional only and currently used only by Windows OS.
Signed-off-by: Kirtana Ashok <kiashok@microsoft.com>
return specs.Platform{}, fmt.Errorf("%q: wildcards not yet supported: %w", specifier, errInvalidArgument)
187
193
}
188
194
189
-
parts:=strings.Split(specifier, "/")
195
+
// Limit to 4 elements to prevent unbounded split
196
+
parts:=strings.SplitN(specifier, "/", 4)
190
197
191
-
for_, part:=rangeparts {
192
-
if!specifierRe.MatchString(part) {
193
-
return specs.Platform{}, fmt.Errorf("%q is an invalid component of %q: platform specifier component must match %q: %w", part, specifier, specifierRe.String(), errInvalidArgument)
198
+
varp specs.Platform
199
+
fori, part:=rangeparts {
200
+
ifi==0 {
201
+
// First element is <os>[(<OSVersion>)]
202
+
osVer:=osAndVersionRe.FindStringSubmatch(part)
203
+
ifosVer==nil {
204
+
return specs.Platform{}, fmt.Errorf("%q is an invalid OS component of %q: OSAndVersion specifier component must match %q: %w", part, specifier, osAndVersionRe.String(), errInvalidArgument)
205
+
}
206
+
207
+
p.OS=normalizeOS(osVer[1])
208
+
p.OSVersion=osVer[2]
209
+
} else {
210
+
if!specifierRe.MatchString(part) {
211
+
return specs.Platform{}, fmt.Errorf("%q is an invalid component of %q: platform specifier component must match %q: %w", part, specifier, specifierRe.String(), errInvalidArgument)
212
+
}
194
213
}
195
214
}
196
215
197
-
varp specs.Platform
198
216
switchlen(parts) {
199
217
case1:
200
-
// in this case, we will test that the value might be an OS, then look
201
-
// it up. If it is not known, we'll treat it as an architecture. Since
218
+
// in this case, we will test that the value might be an OS (with or
219
+
// without the optional OSVersion specified) and look it up.
220
+
// If it is not known, we'll treat it as an architecture. Since
202
221
// we have very little information about the platform here, we are
203
222
// going to be a little more strict if we don't know about the argument
0 commit comments