Skip to content

Commit

Permalink
Merge branch 'master' into fix-libhwui-crash
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlmightyBob committed May 29, 2023
2 parents 893ee82 + 3928573 commit 3e10664
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,23 @@ public void onPageFinished(WebView webView, String url) {
}

@Override
public void onPageStarted(WebView webView, String url, Bitmap favicon) {
super.onPageStarted(webView, url, favicon);
mLastLoadFailed = false;
public void doUpdateVisitedHistory (WebView webView, String url, boolean isReload) {
super.doUpdateVisitedHistory(webView, url, isReload);

((RNCWebView) webView).dispatchEvent(
webView,
new TopLoadingStartEvent(
RNCWebViewWrapper.getReactTagFromWebView(webView),
createWebViewEvent(webView, url)));
}

RNCWebView reactWebView = (RNCWebView) webView;
reactWebView.callInjectedJavaScriptBeforeContentLoaded();
int reactTag = RNCWebViewWrapper.getReactTagFromWebView(reactWebView);
@Override
public void onPageStarted(WebView webView, String url, Bitmap favicon) {
super.onPageStarted(webView, url, favicon);
mLastLoadFailed = false;

UIManagerHelper.getEventDispatcherForReactTag((ReactContext) webView.getContext(), reactTag).dispatchEvent(new TopLoadingStartEvent(
reactTag,
createWebViewEvent(webView, url)));
RNCWebView reactWebView = (RNCWebView) webView;
reactWebView.callInjectedJavaScriptBeforeContentLoaded();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import java.net.MalformedURLException
import java.net.URL
import java.util.*

val invalidCharRegex = "[\\\\/%\"]".toRegex()


class RNCWebViewManagerImpl {
companion object {
Expand Down Expand Up @@ -99,7 +101,11 @@ class RNCWebViewManagerImpl {
Log.w(TAG, "Unsupported URI, aborting download", e)
return@DownloadListener
}
val fileName = URLUtil.guessFileName(url, contentDisposition, mimetype)
var fileName = URLUtil.guessFileName(url, contentDisposition, mimetype)

// Sanitize filename by replacing invalid characters with "_"
fileName = fileName.replace(invalidCharRegex, "_")

val downloadMessage = "Downloading $fileName"

//Attempt to add cookie, if it exists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import java.io.File;
import java.io.IOException;
import java.lang.SecurityException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -305,7 +306,7 @@ public void downloadFile(String downloadingMessage) {

try {
dm.enqueue(mDownloadRequest);
} catch (IllegalArgumentException e) {
} catch (IllegalArgumentException | SecurityException e) {
Log.w("RNCWebViewModule", "Unsupported URI, aborting download", e);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"Thibault Malbranche <malbranche.thibault@gmail.com>"
],
"license": "MIT",
"version": "12.0.2",
"version": "12.1.0",
"homepage": "https://github.com/react-native-webview/react-native-webview#readme",
"scripts": {
"android": "react-native run-android",
Expand Down
4 changes: 2 additions & 2 deletions src/WebView.android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
defaultOriginWhitelist,
defaultRenderError,
defaultRenderLoading,
useWebWiewLogic,
useWebViewLogic,
} from './WebViewShared';
import {
AndroidWebViewProps, WebViewSourceUri,
Expand Down Expand Up @@ -79,7 +79,7 @@ const WebViewComponent = forwardRef<{}, AndroidWebViewProps>(({
}
}, []);

const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onHttpError, onLoadingError, onLoadingFinish, onLoadingProgress, onRenderProcessGone } = useWebWiewLogic({
const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onHttpError, onLoadingError, onLoadingFinish, onLoadingProgress, onRenderProcessGone } = useWebViewLogic({
onNavigationStateChange,
onLoad,
onError,
Expand Down
4 changes: 2 additions & 2 deletions src/WebView.ios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
defaultOriginWhitelist,
defaultRenderError,
defaultRenderLoading,
useWebWiewLogic,
useWebViewLogic,
} from './WebViewShared';
import {
IOSWebViewProps,
Expand Down Expand Up @@ -93,7 +93,7 @@ const WebViewComponent = forwardRef<{}, IOSWebViewProps>(({
RNCWebViewModule.shouldStartLoadWithLockIdentifier(shouldStart, lockIdentifier);
}, []);

const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onHttpError, onLoadingError, onLoadingFinish, onLoadingProgress, onContentProcessDidTerminate } = useWebWiewLogic({
const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onHttpError, onLoadingError, onLoadingFinish, onLoadingProgress, onContentProcessDidTerminate } = useWebViewLogic({
onNavigationStateChange,
onLoad,
onError,
Expand Down
4 changes: 2 additions & 2 deletions src/WebView.macos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
defaultOriginWhitelist,
defaultRenderError,
defaultRenderLoading,
useWebWiewLogic,
useWebViewLogic,
} from './WebViewShared';
import {
MacOSWebViewProps,
Expand Down Expand Up @@ -75,7 +75,7 @@ const WebViewComponent = forwardRef<{}, MacOSWebViewProps>(({
RNCWebViewModule.shouldStartLoadWithLockIdentifier(!!shouldStart, lockIdentifier);
}, []);

const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onHttpError, onLoadingError, onLoadingFinish, onLoadingProgress, onContentProcessDidTerminate } = useWebWiewLogic({
const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onHttpError, onLoadingError, onLoadingFinish, onLoadingProgress, onContentProcessDidTerminate } = useWebViewLogic({
onNavigationStateChange,
onLoad,
onError,
Expand Down
4 changes: 2 additions & 2 deletions src/WebView.windows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
import invariant from 'invariant';
import {RCTWebView, RCTWebView2} from "./WebViewNativeComponent.windows";
import { useWebWiewLogic, defaultOriginWhitelist, defaultRenderError, defaultRenderLoading, } from './WebViewShared';
import { useWebViewLogic, defaultOriginWhitelist, defaultRenderError, defaultRenderLoading, } from './WebViewShared';
import {
NativeWebViewWindows,
WindowsWebViewProps,
Expand Down Expand Up @@ -71,7 +71,7 @@ const WebViewComponent = forwardRef<{}, WindowsWebViewProps>(({
}
}, [RCTWebViewString]);

const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onHttpError, onLoadingError, onLoadingFinish, onLoadingProgress } = useWebWiewLogic({
const { onLoadingStart, onShouldStartLoadWithRequest, onMessage, viewState, setViewState, lastErrorEvent, onHttpError, onLoadingError, onLoadingFinish, onLoadingProgress } = useWebViewLogic({
onNavigationStateChange,
onLoad,
onError,
Expand Down
2 changes: 1 addition & 1 deletion src/WebViewShared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export {
defaultRenderError,
};

export const useWebWiewLogic = ({
export const useWebViewLogic = ({
startInLoadingState,
onNavigationStateChange,
onLoadStart,
Expand Down
2 changes: 1 addition & 1 deletion windows/ReactNativeWebView/ReactNativeWebView.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<ApplicationType>Windows Store</ApplicationType>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.15063.0</WindowsTargetPlatformMinVersion>
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<ItemGroup Label="ProjectConfigurations">
Expand Down

0 comments on commit 3e10664

Please sign in to comment.