File tree 2 files changed +18
-2
lines changed
Sources/PackageDescription 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,9 @@ extension Version: LosslessStringConvertible {
72
72
if let prereleaseDelimiterIndex = prereleaseDelimiterIndex {
73
73
let prereleaseStartIndex = versionString. index ( after: prereleaseDelimiterIndex)
74
74
let prereleaseIdentifiers = versionString [ prereleaseStartIndex..< ( metadataDelimiterIndex ?? versionString. endIndex) ] . split ( separator: " . " , omittingEmptySubsequences: false )
75
- guard prereleaseIdentifiers. allSatisfy ( { $0. allSatisfy ( { $0. isLetter || $0. isNumber || $0 == " - " } ) } ) else { return nil }
75
+ guard prereleaseIdentifiers. allSatisfy ( {
76
+ $0. allSatisfy ( { $0. isASCII && ( $0. isLetter || $0. isNumber || $0 == " - " ) } )
77
+ } ) else { return nil }
76
78
self . prereleaseIdentifiers = prereleaseIdentifiers. map { String ( $0) }
77
79
} else {
78
80
self . prereleaseIdentifiers = [ ]
@@ -81,7 +83,9 @@ extension Version: LosslessStringConvertible {
81
83
if let metadataDelimiterIndex = metadataDelimiterIndex {
82
84
let metadataStartIndex = versionString. index ( after: metadataDelimiterIndex)
83
85
let buildMetadataIdentifiers = versionString [ metadataStartIndex... ] . split ( separator: " . " , omittingEmptySubsequences: false )
84
- guard buildMetadataIdentifiers. allSatisfy ( { $0. allSatisfy ( { $0. isLetter || $0. isNumber || $0 == " - " } ) } ) else { return nil }
86
+ guard buildMetadataIdentifiers. allSatisfy ( {
87
+ $0. allSatisfy ( { $0. isASCII && ( $0. isLetter || $0. isNumber || $0 == " - " ) } )
88
+ } ) else { return nil }
85
89
self . buildMetadataIdentifiers = buildMetadataIdentifiers. map { String ( $0) }
86
90
} else {
87
91
self . buildMetadataIdentifiers = [ ]
Original file line number Diff line number Diff line change @@ -68,6 +68,18 @@ public struct Version {
68
68
buildMetadataIdentifiers: [ String ] = [ ]
69
69
) {
70
70
precondition ( major >= 0 && minor >= 0 && patch >= 0 , " Negative versioning is invalid. " )
71
+ precondition (
72
+ prereleaseIdentifiers. allSatisfy {
73
+ $0. allSatisfy { $0. isASCII && ( $0. isLetter || $0. isNumber || $0 == " - " ) }
74
+ } ,
75
+ #"Pre-release identifiers can contain only ASCII alpha-numeric characters and "-"."#
76
+ )
77
+ precondition (
78
+ buildMetadataIdentifiers. allSatisfy {
79
+ $0. allSatisfy { $0. isASCII && ( $0. isLetter || $0. isNumber || $0 == " - " ) }
80
+ } ,
81
+ #"Build metadata identifiers can contain only ASCII alpha-numeric characters and "-"."#
82
+ )
71
83
self . major = major
72
84
self . minor = minor
73
85
self . patch = patch
You can’t perform that action at this time.
0 commit comments