@@ -267,7 +267,8 @@ void main() {
267
267
expect (fixture.options.dist, '789' );
268
268
});
269
269
270
- test ('release name does not contain ivalid chars' , () async {
270
+ test ('release name does not contain invalid chars defined by Sentry' ,
271
+ () async {
271
272
final loader = () {
272
273
return Future .value (PackageInfo (
273
274
appName: '\\ /sentry\t flutter \r\n foo\n bar\r ' ,
@@ -283,6 +284,69 @@ void main() {
283
284
expect (fixture.options.release,
'__sentry_flutter [email protected] +789' );
284
285
expect (fixture.options.dist, '789' );
285
286
});
287
+
288
+ /// See the following issues:
289
+ /// - https://github.com/getsentry/sentry-dart/issues/410
290
+ /// - https://github.com/fluttercommunity/plus_plugins/issues/182
291
+ test ('does not send Unicode NULL \\ u0000 character in app name or version' ,
292
+ () async {
293
+ final loader = () {
294
+ return Future .value (PackageInfo (
295
+ // As per
296
+ // https://api.dart.dev/stable/2.12.4/dart-core/String-class.html
297
+ // this is how \u0000 is added to a string in dart
298
+ appName: 'sentry_flutter_example\u {0000}' ,
299
+ packageName: '' ,
300
+ version: '1.0.0\u {0000}' ,
301
+ buildNumber: '' ,
302
+ ));
303
+ };
304
+ await fixture
305
+ .getIntegration (loader: loader)
306
+ .call (MockHub (), fixture.options);
307
+
308
+ expect (fixture.options.release,
'[email protected] ' );
309
+ });
310
+
311
+ /// See the following issues:
312
+ /// - https://github.com/getsentry/sentry-dart/issues/410
313
+ /// - https://github.com/fluttercommunity/plus_plugins/issues/182
314
+ test (
315
+ 'does not send Unicode NULL \\ u0000 character in package name or build number' ,
316
+ () async {
317
+ final loader = () {
318
+ return Future .value (PackageInfo (
319
+ // As per
320
+ // https://api.dart.dev/stable/2.12.4/dart-core/String-class.html
321
+ // this is how \u0000 is added to a string in dart
322
+ appName: '' ,
323
+ packageName: 'sentry_flutter_example\u {0000}' ,
324
+ version: '' ,
325
+ buildNumber: '123\u {0000}' ,
326
+ ));
327
+ };
328
+ await fixture
329
+ .getIntegration (loader: loader)
330
+ .call (MockHub (), fixture.options);
331
+
332
+ expect (fixture.options.release, 'sentry_flutter_example+123' );
333
+ });
334
+
335
+ test ('dist is null if build number is an empty string' , () async {
336
+ final loader = () {
337
+ return Future .value (PackageInfo (
338
+ appName: 'sentry_flutter_example' ,
339
+ packageName: 'a.b.c' ,
340
+ version: '1.0.0' ,
341
+ buildNumber: '' ,
342
+ ));
343
+ };
344
+ await fixture
345
+ .getIntegration (loader: loader)
346
+ .call (MockHub (), fixture.options);
347
+
348
+ expect (fixture.options.dist, isNull);
349
+ });
286
350
});
287
351
}
288
352
0 commit comments