Skip to content
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

Fix: networkSchemas should be nullable for handling relative path image src #1437

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/flutter_html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export 'package:flutter_html/src/anchor.dart';
export 'package:flutter_html/src/tree/interactable_element.dart';
export 'package:flutter_html/src/tree/replaced_element.dart';
export 'package:flutter_html/src/tree/styled_element.dart';
export 'package:flutter_html/src/tree/image_element.dart';
//export css_box_widget for use in extensions.
export 'package:flutter_html/src/css_box_widget.dart';
//export style api
Expand Down
7 changes: 3 additions & 4 deletions lib/src/builtins/image_builtin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_html/src/tree/image_element.dart';

class ImageBuiltIn extends HtmlExtension {
final String? dataEncoding;
final Set<String>? mimeTypes;
final Map<String, String>? networkHeaders;
final Set<String> networkSchemas;
final Set<String>? networkSchemas;
final Set<String>? networkDomains;
final Set<String>? fileExtensions;

Expand All @@ -23,7 +22,7 @@ class ImageBuiltIn extends HtmlExtension {
const ImageBuiltIn({
this.networkHeaders,
this.networkDomains,
this.networkSchemas = const {"http", "https"},
this.networkSchemas,
this.fileExtensions,
this.assetSchema = "asset:",
this.assetBundle,
Expand Down Expand Up @@ -146,7 +145,7 @@ class ImageBuiltIn extends HtmlExtension {
}

return context.elementName == "img" &&
networkSchemas.contains(src.scheme) &&
(networkSchemas == null || networkSchemas!.contains(src.scheme)) &&
!src.path.endsWith(".svg") &&
(networkDomains == null || networkDomains!.contains(src.host)) &&
(fileExtensions == null ||
Expand Down
4 changes: 2 additions & 2 deletions lib/src/extension/helpers/image_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ImageExtension extends ImageBuiltIn {
super.mimeTypes,
super.networkDomains,
super.networkHeaders,
super.networkSchemas = const {"http", "https"},
super.networkSchemas,
super.handleAssetImages = true,
super.handleDataImages = true,
super.handleNetworkImages = true,
Expand All @@ -43,7 +43,7 @@ class ImageExtension extends ImageBuiltIn {
super.mimeTypes,
super.networkDomains,
super.networkHeaders,
super.networkSchemas = const {"http", "https"},
super.networkSchemas,
super.handleAssetImages = true,
super.handleDataImages = true,
super.handleNetworkImages = true,
Expand Down
1 change: 0 additions & 1 deletion packages/flutter_html_svg/lib/flutter_html_svg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
// ignore: implementation_imports
import 'package:flutter_html/src/tree/image_element.dart';
import 'package:flutter_svg/flutter_svg.dart';

// TODO re-add MultipleGestureDetector for image taps in this extension
Expand Down