mirror of https://github.com/M66B/FairEmail.git
Whitelist AMP CDN
This commit is contained in:
parent
1b6af01131
commit
7dae271865
|
@ -38,6 +38,9 @@ import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
|
import org.jsoup.nodes.Document;
|
||||||
|
import org.jsoup.nodes.Element;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
@ -130,10 +133,21 @@ public class ActivityAMP extends ActivityBase {
|
||||||
throw new IllegalArgumentException(context.getString(R.string.title_no_stream));
|
throw new IllegalArgumentException(context.getString(R.string.title_no_stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String html;
|
||||||
ContentResolver resolver = context.getContentResolver();
|
ContentResolver resolver = context.getContentResolver();
|
||||||
try (InputStream is = resolver.openInputStream(uri)) {
|
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
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue