Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android WebView unable to execute Javascript when html has a special character ✓

Javascript is not getting executed when the below code is loaded in Android WebView.

Issue is seen only when the input box with a value of ✓ is being included in the html. Refer the text input field in the code given below with the name "utf8".

This input and its value is returned by a payment gateway provider, It's part of their form data, which needs to be submitted to their domain url to complete the payment. Hence the value and the html cannot be altered.

<!DOCTYPE html>
<html>
	<head>
	  <title></title>
	</head>
	<body>
	<form action=“” accept-charset=“UTF-8” method=“post”>
	   <input name=“utf8” type=“hidden” value=“&#x2713;” />
	</form>
	<script>
		alert("hello world");
	</script>
	</body>
</html>

Issue is seen on :

  • Samsung Galaxy S7, Android version 8.0.0
  • One Plus 5, Android version 9

Working perfectly on:

  • Motog 5s Plus, Android version 8.1.0
  • Samsung J2, Android version 5.1.1
like image 498
ASKN Avatar asked Feb 05 '19 14:02

ASKN


1 Answers

The solution for me was to replace # with %23.

From Chrome 72 update webview treats the # as the end of content: https://www.chromestatus.com/feature/5656049583390720

like image 53
Nejc Avatar answered Oct 17 '22 01:10

Nejc