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

JavaScript was disabled #271

Merged
Merged
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
16 changes: 9 additions & 7 deletions src/Eppie.App/Eppie.App.Shared/Extensions/WebViewExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@ namespace Tuvi.App.Shared.Extensions
{
public static class WebViewExtension
{
public static string GetStringSource(DependencyObject obj)
public static string GetStringSourceWithDisabledJavaScript(DependencyObject obj)
{
return (string)obj?.GetValue(StringSourceProperty);
return (string)obj?.GetValue(StringSourceWithDisabledJavaScriptProperty);
}

public static void SetStringSource(DependencyObject obj, string value)
public static void SetStringSourceWithDisabledJavaScript(DependencyObject obj, string value)
{
obj?.SetValue(StringSourceProperty, value);
obj?.SetValue(StringSourceWithDisabledJavaScriptProperty, value);
}

public static readonly DependencyProperty StringSourceProperty =
DependencyProperty.RegisterAttached("StringSource", typeof(string), typeof(WebViewExtension), new PropertyMetadata("", OnStringSourcePropertyChanged));
private static void OnStringSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
public static readonly DependencyProperty StringSourceWithDisabledJavaScriptProperty =
DependencyProperty.RegisterAttached("StringSourceWithDisabledJavaScript", typeof(string), typeof(WebViewExtension), new PropertyMetadata("", OnStringSourceWithDisabledJavaScriptPropertyChanged));
private static void OnStringSourceWithDisabledJavaScriptPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is WebView webView)
{
webView.Settings.IsJavaScriptEnabled = false;

webView.NavigateToString(e.NewValue as string ?? "");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Eppie.App/Eppie.App.Shared/Views/MessagePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
BorderBrush="#FFE0E0E0"
BorderThickness="1">

<WebView extensions:WebViewExtension.StringSource="{x:Bind ViewModel.MessageInfo.MessageHtmlBody, Mode=OneWay}"
<WebView extensions:WebViewExtension.StringSourceWithDisabledJavaScript="{x:Bind ViewModel.MessageInfo.MessageHtmlBody, Mode=OneWay}"
Visibility="{x:Bind ViewModel.MessageInfo.HasHtmlBody, Mode=OneWay}" />

<ScrollViewer Padding="4"
Expand Down
Loading