-
-
Notifications
You must be signed in to change notification settings - Fork 257
Fix: Trim Unicode NULL character for Windows support #420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
69541b2
a2b8218
03a041e
3c53608
109e5bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -373,12 +373,24 @@ class LoadReleaseIntegration extends Integration<SentryFlutterOptions> { | |
name = _cleanAppName(packageInfo.appName); | ||
} | ||
|
||
final release = | ||
'$name@${packageInfo.version}+${packageInfo.buildNumber}'; | ||
final version = _cleanAppName(packageInfo.version); | ||
final buildNumber = _cleanAppName(packageInfo.buildNumber); | ||
|
||
var release = name; | ||
if (version.isNotEmpty) { | ||
release = '$release@$version'; | ||
} | ||
// At least windows sometimes does not have a buildNumber | ||
if (buildNumber.isNotEmpty) { | ||
release = '$release+$buildNumber'; | ||
} | ||
|
||
options.logger(SentryLevel.debug, 'release: $release'); | ||
|
||
options.release = options.release ?? release; | ||
options.dist = options.dist ?? packageInfo.buildNumber; | ||
if (buildNumber.isNotEmpty) { | ||
options.dist = options.dist ?? packageInfo.buildNumber; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might need check the format of build number. Will this always be in a valid format as per Sentry's spec? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #422
ueman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} catch (error) { | ||
options.logger( | ||
|
@@ -397,6 +409,7 @@ class LoadReleaseIntegration extends Integration<SentryFlutterOptions> { | |
.replaceAll('\t', '_') | ||
.replaceAll('\r\n', '_') | ||
.replaceAll('\r', '_') | ||
.replaceAll('\n', '_'); | ||
.replaceAll('\n', '_') | ||
.replaceAll('\u{0000}', ''); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to be sure that this works on Windows, maybe @bruno-garcia can test it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dream of integration test on the target platform that will validate these for us. Mainly because of regressions introduced later. Thoughts? Q2 is the time to plan and book these tasks |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,7 +267,8 @@ void main() { | |
expect(fixture.options.dist, '789'); | ||
}); | ||
|
||
test('release name does not contain ivalid chars', () async { | ||
test('release name does not contain invalid chars defined by Sentry', | ||
() async { | ||
final loader = () { | ||
return Future.value(PackageInfo( | ||
appName: '\\/sentry\tflutter \r\nfoo\nbar\r', | ||
|
@@ -283,6 +284,44 @@ void main() { | |
expect(fixture.options.release, '__sentry_flutter [email protected]+789'); | ||
expect(fixture.options.dist, '789'); | ||
}); | ||
|
||
/// See the following issues: | ||
/// - https://github.com/getsentry/sentry-dart/issues/410 | ||
/// - https://github.com/fluttercommunity/plus_plugins/issues/182 | ||
test('uses acceptable release name on windows', () async { | ||
final loader = () { | ||
return Future.value(PackageInfo( | ||
// As per | ||
// https://api.dart.dev/stable/2.12.4/dart-core/String-class.html | ||
// this is how \u0000 is added to a string in dart | ||
appName: 'sentry_flutter_example\u{0000}', | ||
packageName: '', | ||
version: '1.0.0\u{0000}', | ||
buildNumber: '', | ||
)); | ||
}; | ||
await fixture | ||
.getIntegration(loader: loader) | ||
.call(MockHub(), fixture.options); | ||
|
||
expect(fixture.options.release, '[email protected]'); | ||
}); | ||
|
||
test('dist is null if build number is an empty string', () async { | ||
final loader = () { | ||
return Future.value(PackageInfo( | ||
appName: 'sentry_flutter_example', | ||
packageName: 'a.b.c', | ||
version: '1.0.0', | ||
buildNumber: '', | ||
)); | ||
}; | ||
await fixture | ||
.getIntegration(loader: loader) | ||
.call(MockHub(), fixture.options); | ||
|
||
expect(fixture.options.dist, isNull); | ||
}); | ||
}); | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.