Skip to content

Commit

Permalink
Merge pull request #35 from Joran-Dob/13-add-validation-for-content-t…
Browse files Browse the repository at this point in the history
…ype-heade

13 Add validation for content-type header and fix for a semicolon. 🚨
  • Loading branch information
Joran-Dob authored Nov 27, 2020
2 parents 916e72d + 59a09a9 commit 3a04e4e
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/flutter-drive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
# https://github.com/marketplace/actions/flutter-action
- uses: subosito/flutter-action@v1
with:
channel: "stable"
channel: "dev"
- run: flutter pub get
- name: Format
run: flutter format --set-exit-if-changed lib test example
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/flutter-release-drive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# https://github.com/marketplace/actions/flutter-action
- uses: subosito/flutter-action@v1
with:
channel: "stable"
channel: "dev"
- run: flutter pub get
- name: Format
run: flutter format --set-exit-if-changed lib test example
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [1.0.4] - 27 november 2020.

* Added a check to see if content-types end with a semicolon 👀.
* Added a fix for content-types that end with a semicolon 👨‍🔧.

## [1.0.3] - 6 october 2020.

* Added more tests and completer coverage.
Expand Down
2 changes: 1 addition & 1 deletion example/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"video_player","path":"/Users/joran.dob/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player-0.10.9+1/","dependencies":[]},{"name":"wakelock","path":"/Users/joran.dob/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock-0.1.4+1/","dependencies":[]}],"android":[{"name":"video_player","path":"/Users/joran.dob/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player-0.10.9+1/","dependencies":[]},{"name":"wakelock","path":"/Users/joran.dob/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock-0.1.4+1/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[{"name":"video_player_web","path":"/Users/joran.dob/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_web-0.1.2+3/","dependencies":[]}]},"dependencyGraph":[{"name":"video_player","dependencies":["video_player_web"]},{"name":"video_player_web","dependencies":[]},{"name":"wakelock","dependencies":[]}],"date_created":"2020-10-08 16:02:54.078780","version":"1.23.0-7.0.pre"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"video_player","path":"/Users/joran.dob/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player-0.10.9+1/","dependencies":[]},{"name":"wakelock","path":"/Users/joran.dob/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock-0.1.4+1/","dependencies":[]}],"android":[{"name":"video_player","path":"/Users/joran.dob/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player-0.10.9+1/","dependencies":[]},{"name":"wakelock","path":"/Users/joran.dob/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock-0.1.4+1/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[{"name":"video_player_web","path":"/Users/joran.dob/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_web-0.1.2+3/","dependencies":[]}]},"dependencyGraph":[{"name":"video_player","dependencies":["video_player_web"]},{"name":"video_player_web","dependencies":[]},{"name":"wakelock","dependencies":[]}],"date_created":"2020-11-27 12:12:11.983891","version":"1.24.0-10.2.pre"}
61 changes: 34 additions & 27 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety.1"
version: "2.5.0-nullsafety.3"
bloc:
dependency: transitive
description:
name: bloc
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.1"
version: "6.1.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.1.0-nullsafety.3"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0-nullsafety.5"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0-nullsafety.3"
chewie:
dependency: "direct main"
description:
Expand All @@ -49,14 +49,14 @@ packages:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.1.0-nullsafety.3"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.3"
version: "1.15.0-nullsafety.5"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -70,14 +70,14 @@ packages:
name: equatable
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.5"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0-nullsafety.3"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -89,7 +89,7 @@ packages:
name: flutter_bloc
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.1"
version: "6.1.1"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -106,28 +106,35 @@ packages:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0+2"
version: "0.12.2"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.4"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3-nullsafety.3"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety.1"
version: "0.12.10-nullsafety.3"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0-nullsafety.6"
nested:
dependency: transitive
description:
Expand All @@ -148,21 +155,21 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.1"
version: "1.8.0-nullsafety.3"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.1"
version: "1.9.2"
provider:
dependency: transitive
description:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.3"
version: "4.3.2+2"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -174,63 +181,63 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.2"
version: "1.8.0-nullsafety.4"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.1"
version: "1.10.0-nullsafety.6"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.1.0-nullsafety.3"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.1.0-nullsafety.3"
subtitle_wrapper_package:
dependency: "direct main"
dependency: "direct dev"
description:
path: ".."
relative: true
source: path
version: "1.0.3"
version: "1.0.4"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0-nullsafety.3"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety.2"
version: "0.2.19-nullsafety.6"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0-nullsafety.5"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0-nullsafety.5"
video_player:
dependency: "direct main"
description:
Expand Down Expand Up @@ -260,5 +267,5 @@ packages:
source: hosted
version: "0.1.4+1"
sdks:
dart: ">=2.10.0-110 <=2.11.0-161.0.dev"
dart: ">=2.12.0-0.0 <3.0.0"
flutter: ">=1.16.0 <2.0.0"
7 changes: 2 additions & 5 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ dependencies:
sdk: flutter
chewie: ^0.9.10
video_player: ^0.10.9+1
subtitle_wrapper_package:
path: ../
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2

dev_dependencies:
flutter_test:
sdk: flutter

subtitle_wrapper_package:
path: ../

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down
3 changes: 1 addition & 2 deletions lib/bloc/subtitle/subtitle_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import 'package:subtitle_wrapper_package/data/models/subtitle.dart';
import 'package:subtitle_wrapper_package/data/models/subtitles.dart';
import 'package:subtitle_wrapper_package/data/repository/subtitle_repository.dart';
import 'package:subtitle_wrapper_package/subtitle_controller.dart';
import 'package:video_player/video_player.dart';

part 'subtitle_event.dart';
part 'subtitle_state.dart';

class SubtitleBloc extends Bloc<SubtitleEvent, SubtitleState> {
final VideoPlayerController videoPlayerController;
final dynamic videoPlayerController;
final SubtitleRepository subtitleRepository;
final SubtitleController subtitleController;

Expand Down
17 changes: 15 additions & 2 deletions lib/data/repository/subtitle_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,21 @@ class SubtitleDataRepository extends SubtitleRepository {

// Gets the content type from the headers and returns it as a media type
MediaType _contentTypeForHeaders(Map<String, String> headers) {
var contentType = headers['content-type'];
return MediaType.parse(contentType);
var _contentType = headers['content-type'];
if (_hasSemiColonEnding(_contentType)) {
_contentType = _fixSemiColonEnding(_contentType);
}
return MediaType.parse(_contentType);
}

// Check if the string is ending with a semicolon.
bool _hasSemiColonEnding(String _string) {
return _string.substring(_string.length - 1, _string.length) == ';';
}

// Remove ending semicolon from string.
String _fixSemiColonEnding(String _string) {
return _string.substring(0, _string.length - 1);
}

// Gets the encoding type for the charset string with a fall back to utf8
Expand Down
3 changes: 1 addition & 2 deletions lib/subtitle_wrapper_package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import 'package:subtitle_wrapper_package/data/models/style/subtitle_style.dart';
import 'package:subtitle_wrapper_package/data/repository/subtitle_repository.dart';
import 'package:subtitle_wrapper_package/subtitle_controller.dart';
import 'package:subtitle_wrapper_package/subtitle_text_view.dart';
import 'package:video_player/video_player.dart';

class SubTitleWrapper extends StatelessWidget {
final Widget videoChild;
final SubtitleController subtitleController;
final VideoPlayerController videoPlayerController;
final dynamic videoPlayerController;
final SubtitleStyle subtitleStyle;

SubTitleWrapper({
Expand Down
Loading

0 comments on commit 3a04e4e

Please sign in to comment.