Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VB6: AddWebResourceRequestedFilter and ico, svg not blocked
#2
Hi Przemek,

Looks like Microsoft determined those are not image or media files.

In order to figure that out I adjusted your code a bit like so:
Code:
Private Sub EdgeWebBrowser_OnWebResourceRequested(ByVal Args As AntViewAx.IAntViewWebResourceRequestedEventArgs)

  Dim NewResponse As AntViewWebResourceResponse
  If Args.ResourceContext = rcImage Then
    Set NewResponse = EdgeWebBrowser.CreateWebResourceResponse("", 403, "Blocked", "")
    Args.Response = NewResponse
    Exit Sub
  End If

  If Args.ResourceContext = rcMedia Then
    Set NewResponse = EdgeWebBrowser.CreateWebResourceResponse("", 403, "Blocked", "")
    Args.Response = NewResponse
    Exit Sub
  End If

  If Args.ResourceContext = rcScript Then
    Set NewResponse = EdgeWebBrowser.CreateWebResourceResponse("", 403, "Blocked", "")
    Args.Response = NewResponse
    Exit Sub
  End If

  If Args.ResourceContext = rcStylesheet Then
    Set NewResponse = EdgeWebBrowser.CreateWebResourceResponse("", 403, "Blocked", "")
    Args.Response = NewResponse
    Exit Sub
  End If

  If Args.ResourceContext = rcFont Then
    Set NewResponse = EdgeWebBrowser.CreateWebResourceResponse("", 403, "Blocked", "")
    Args.Response = NewResponse
    Exit Sub
  End If

  'If Args.ResourceContext = rcOther Then
  '  Set NewResponse = EdgeWebBrowser.CreateWebResourceResponse("", 403, "Blocked", "")
  '  Args.Response = NewResponse
  '  Exit Sub
  'End If
 
  Debug.Print Args.Request.URI & " - " & Args.ResourceContext
 
End Sub

Private Sub EdgeWebBrowser_OnWebResourceResponseReceived(ByVal Request As AntViewAx.IAntViewWebResourceRequest, ByVal Response As AntViewAx.IAntViewWebResourceResponseView)
If Response.StatusCode <> 403 Then
    Debug.Print Response.StatusCode & " - " & Request.URI
     'Status: 200 - https://www.interia.pl/favicon.svg
     'Status: 200 - https://www.interia.pl/favicon.ico
End If
End Sub

Private Sub TestButton_Click()
  EdgeWebBrowser.WebResourceResponseReceivedEnabled = True
  EdgeWebBrowser.AddWebResourceRequestedFilter "*", rcAll
End Sub

So basically I'm using the first debug.print to find out what the resourceContext is that Microsoft assigned for the file type.

This tells me that an svg file is declared as rcOther as is a favicon.ico.

You can see this as it reports the following in the output window:
Code:
https://www.antwise.com/ - 1
200 - https://www.antwise.com/
200 - https://www.antwise.com/css/reset.css
200 - https://www.antwise.com/css/screen.css
200 - https://www.antwise.com/images/siteid.png
200 - https://www.antwise.com/images/opensource.png
200 - https://www.antwise.com/images/banner.png
200 - https://www.antwise.com/images/footer.png
https://www.antwise.com/favicon.ico - 16
200 - https://www.antwise.com/favicon.ico
So code 16 for the favicon.
If you look at up here: https://doc.antview.dev/hs335.htm then you'll notice that 16 = rcOther.

Same thing if you go to your website and look for the .svg file in the debug output.

Also note that you can't seem to block images if they are streamed as imagedata.
--
Wil
Reply


Messages In This Thread
RE: VB6: AddWebResourceRequestedFilter and ico, svg not blocked - by wila - 2023-08-08, 13:45:13

Forum Jump:


Users browsing this thread: 1 Guest(s)