Commit 76358d98 by ibaker Committed by Oliver Woodman

Base64 encode the subtitle HTML before passing to WebView.loadData

Without this, URL-encoding is assumed, which means ampersand-codes are
not carried through to the underlying web page correctly.

PiperOrigin-RevId: 304163733
parent 5392a2f4
......@@ -23,13 +23,16 @@ import android.content.Context;
import android.graphics.Color;
import android.text.Layout;
import android.util.AttributeSet;
import android.util.Base64;
import android.view.MotionEvent;
import android.view.ViewGroup;
import android.webkit.WebView;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.text.CaptionStyleCompat;
import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.util.Util;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.List;
......@@ -231,7 +234,11 @@ import java.util.List;
html.append("</div></body></html>");
webView.loadData(html.toString(), "text/html", /* encoding= */ null);
webView.loadData(
Base64.encodeToString(
html.toString().getBytes(Charset.forName(C.UTF8_NAME)), Base64.NO_PADDING),
"text/html",
"base64");
}
private String convertAlignmentToCss(@Nullable Layout.Alignment alignment) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment