mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-24 07:01:05 +00:00
Whitelist AMP CDN
This commit is contained in:
parent
1b6af01131
commit
7dae271865
1 changed files with 15 additions and 1 deletions
|
@ -38,6 +38,9 @@ import androidx.preference.PreferenceManager;
|
|||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -130,10 +133,21 @@ public class ActivityAMP extends ActivityBase {
|
|||
throw new IllegalArgumentException(context.getString(R.string.title_no_stream));
|
||||
}
|
||||
|
||||
String html;
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
try (InputStream is = resolver.openInputStream(uri)) {
|
||||
return Helper.readStream(is);
|
||||
html = Helper.readStream(is);
|
||||
}
|
||||
|
||||
Document d = JsoupEx.parse(html);
|
||||
for (Element script : d.select("script")) {
|
||||
String src = script.attr("src");
|
||||
Uri u = Uri.parse(src);
|
||||
if (!u.isHierarchical() || !"cdn.ampproject.org".equals(u.getHost()))
|
||||
script.removeAttr("src");
|
||||
}
|
||||
|
||||
return d.html();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue