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
194
}
188
195
189
-
parts:=strings.Split(specifier, "/")
196
+
// Limit to 4 elements to prevent unbounded split
197
+
parts:=strings.SplitN(specifier, "/", 4)
190
198
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)
199
+
varp specs.Platform
200
+
fori, part:=rangeparts {
201
+
ifi==0 {
202
+
// First element is <os>[(<OSVersion>)]
203
+
if!osAndVersionRe.MatchString(part) {
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, p.OSVersion=normalizeOSAndVersion(part)
208
+
} else {
209
+
if!specifierRe.MatchString(part) {
210
+
return specs.Platform{}, fmt.Errorf("%q is an invalid component of %q: platform specifier component must match %q: %w", part, specifier, specifierRe.String(), errInvalidArgument)
211
+
}
194
212
}
195
213
}
196
214
197
-
varp specs.Platform
198
215
switchlen(parts) {
199
216
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
217
+
// in this case, we will test that the value might be an OS (with or
218
+
// without the optional OSVersion specified) and look it up.
219
+
// If it is not known, we'll treat it as an architecture. Since
202
220
// we have very little information about the platform here, we are
203
221
// going to be a little more strict if we don't know about the argument
0 commit comments