Skip to content

Commit

Permalink
Fix incorrect image size parsing (filter image tag width/height attri…
Browse files Browse the repository at this point in the history
…bute values in percent)

Update fallback user agents
  • Loading branch information
alim-zanibekov committed Apr 28, 2022
1 parent 1784d76 commit 14ea2e3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 28 deletions.
13 changes: 11 additions & 2 deletions lib/core/parsers/content-parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,15 @@ class ContentParser {
final id = src != null ? getSoundCloudUrl(src) : null;
if (id != null) return ContentUnitSoundCloudAudio(id);
} else if (image != null) {
var width = Utils.getNumberDouble(image.attributes['width']);
var height = Utils.getNumberDouble(image.attributes['height']);
final widthStr = image.attributes['width'] ?? '';
final heightStr = image.attributes['height'] ?? '';

var width = _onlyNumbersRegex.hasMatch(widthStr)
? Utils.getNumberDouble(widthStr)
: null;
var height = _onlyNumbersRegex.hasMatch(heightStr)
? Utils.getNumberDouble(heightStr)
: null;
if (height == null || width == null) {
width = height = null;
}
Expand Down Expand Up @@ -264,6 +271,8 @@ class ContentParser {
return answer;
}

static final _onlyNumbersRegex = RegExp('^[0-9]+\$');

static final _youtubeRegex = RegExp(
r'(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})',
caseSensitive: false,
Expand Down
4 changes: 2 additions & 2 deletions lib/variables.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:io';
class Headers {
static final reactorHeaders = {
HttpHeaders.userAgentHeader: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_'
'4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36',
'7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.83 Safari/537.36',
HttpHeaders.acceptHeader: '*/*',
HttpHeaders.refererHeader: 'http://joyreactor.cc/',
};
Expand All @@ -14,7 +14,7 @@ class Headers {
HttpHeaders.cookieHeader: 'showVideoGif3=1',
HttpHeaders.acceptEncodingHeader: 'identity;q=1, *;q=0',
HttpHeaders.userAgentHeader: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_'
'4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/s537.36',
'7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.83 Safari/537.36',
HttpHeaders.acceptHeader: '*/*',
HttpHeaders.refererHeader: 'http://joyreactor.cc/'
};
Expand Down
46 changes: 23 additions & 23 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ packages:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.2"
version: "3.3.0"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -107,7 +107,7 @@ packages:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
version: "3.0.2"
csslib:
dependency: transitive
description:
Expand All @@ -121,7 +121,7 @@ packages:
name: dbus
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.1"
version: "0.7.3"
decorated_icon:
dependency: "direct main"
description:
Expand All @@ -135,7 +135,7 @@ packages:
name: device_info_plus
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.2"
version: "3.2.3"
device_info_plus_linux:
dependency: transitive
description:
Expand All @@ -149,7 +149,7 @@ packages:
name: device_info_plus_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.2"
version: "2.2.3"
device_info_plus_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -177,7 +177,7 @@ packages:
name: dio
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.4"
version: "4.0.6"
double_back_to_close_app:
dependency: "direct main"
description:
Expand Down Expand Up @@ -224,14 +224,14 @@ packages:
name: flutter_inappwebview
url: "https://pub.dartlang.org"
source: hosted
version: "5.3.2"
version: "5.4.3+4"
flutter_local_notifications:
dependency: "direct main"
description:
name: flutter_local_notifications
url: "https://pub.dartlang.org"
source: hosted
version: "9.4.0"
version: "9.4.1"
flutter_local_notifications_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -386,14 +386,14 @@ packages:
name: package_info_plus
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.0"
version: "1.4.2"
package_info_plus_linux:
dependency: transitive
description:
name: package_info_plus_linux
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
version: "1.0.5"
package_info_plus_macos:
dependency: transitive
description:
Expand All @@ -414,14 +414,14 @@ packages:
name: package_info_plus_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
package_info_plus_windows:
dependency: transitive
description:
name: package_info_plus_windows
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
page_transition:
dependency: "direct main"
description:
Expand Down Expand Up @@ -449,7 +449,7 @@ packages:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.12"
version: "2.0.13"
path_provider_ios:
dependency: transitive
description:
Expand Down Expand Up @@ -512,7 +512,7 @@ packages:
name: permission_handler_apple
url: "https://pub.dartlang.org"
source: hosted
version: "9.0.3"
version: "9.0.4"
permission_handler_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -589,14 +589,14 @@ packages:
name: sentry
url: "https://pub.dartlang.org"
source: hosted
version: "6.4.0"
version: "6.5.1"
share_plus:
dependency: "direct main"
description:
name: share_plus
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.2"
version: "4.0.4"
share_plus_linux:
dependency: transitive
description:
Expand All @@ -617,7 +617,7 @@ packages:
name: share_plus_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
version: "3.0.2"
share_plus_web:
dependency: transitive
description:
Expand Down Expand Up @@ -694,7 +694,7 @@ packages:
name: shelf
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
shelf_packages_handler:
dependency: transitive
description:
Expand Down Expand Up @@ -832,14 +832,14 @@ packages:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.20"
version: "6.1.0"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.15"
version: "6.0.16"
url_launcher_ios:
dependency: transitive
description:
Expand Down Expand Up @@ -943,7 +943,7 @@ packages:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.2.0"
webkit_inspection_protocol:
dependency: transitive
description:
Expand All @@ -957,7 +957,7 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.2"
version: "2.5.2"
xdg_directories:
dependency: transitive
description:
Expand All @@ -980,5 +980,5 @@ packages:
source: hosted
version: "3.1.0"
sdks:
dart: ">=2.15.0 <3.0.0"
dart: ">=2.16.0 <3.0.0"
flutter: ">=2.10.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: reactor
description: JoyReactor client.
version: 0.7.8
version: 0.7.9

environment:
sdk: '>=2.14.0 <3.0.0'
Expand Down

0 comments on commit 14ea2e3

Please sign in to comment.