Skip to content

Commit

Permalink
JavaScript was disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraFinebits committed Jun 25, 2024
1 parent 197836f commit 54d0623
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 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));
public static readonly DependencyProperty StringSourceWithDisabledJavaScriptProperty =
DependencyProperty.RegisterAttached("StringSourceWithDisabledJavaScript", typeof(string), typeof(WebViewExtension), new PropertyMetadata("", OnStringSourcePropertyChanged));
private static void OnStringSourcePropertyChanged(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

0 comments on commit 54d0623

Please sign in to comment.