diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 2171fc52a0ba5..3555822b1f1fa 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -760,7 +760,7 @@ public class WebView extends AbsoluteLayout *

* The {@code encoding} parameter specifies whether the data is base64 or URL * encoded. If the data is base64 encoded, the value of the encoding - * parameter must be 'base64'. HTML can be encoded with {@link + * parameter must be {@code "base64"}. HTML can be encoded with {@link * android.util.Base64#encodeToString(byte[],int)} like so: *

      * String unencodedHtml =
@@ -768,11 +768,15 @@ public class WebView extends AbsoluteLayout
      * String encodedHtml = Base64.encodeToString(unencodedHtml.getBytes(), Base64.NO_PADDING);
      * webView.loadData(encodedHtml, "text/html", "base64");
      * 
- *

+ *

* For all other values of {@code encoding} (including {@code null}) it is assumed that the * data uses ASCII encoding for octets inside the range of safe URL characters and use the * standard %xx hex encoding of URLs for octets outside that range. See RFC 3986 for more information. + * Applications targeting {@link android.os.Build.VERSION_CODES#Q} or later must either use + * base64 or encode any {@code #} characters in the content as {@code %23}, otherwise they + * will be treated as the end of the content and the remaining text used as a document + * fragment identifier. *

* The {@code mimeType} parameter specifies the format of the data. * If WebView can't handle the specified MIME type, it will download the data. @@ -820,7 +824,8 @@ public class WebView extends AbsoluteLayout *

* If the base URL uses the data scheme, this method is equivalent to * calling {@link #loadData(String,String,String) loadData()} and the - * historyUrl is ignored, and the data will be treated as part of a data: URL. + * historyUrl is ignored, and the data will be treated as part of a data: URL, + * including the requirement that the content be URL-encoded or base64 encoded. * If the base URL uses any other scheme, then the data will be loaded into * the WebView as a plain string (i.e. not part of a data URL) and any URL-encoded * entities in the string will not be decoded.