Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
block image/jpeg;base64 using url filter

I using WebViewClient's shouldInterceptRequest function to filter photos in my android webView.

The problem
I'm trying to block google's base64 URL photos (like:data:image/jpeg;base64,+) using this regex data:image/(jpg|png|jpeg);base64, but without success.

I done my research and found that:

these base64 background images are injected with JS.

but I don't know to continue.

my code:

@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
    String url = request.getUrl().toString();
    if (imgCheck(url,res))
    {

        return new WebResourceResponse(
                BrowserUnit.MIME_TYPE_TEXT_PLAIN,
                BrowserUnit.URL_ENCODING,
                new ByteArrayInputStream("".getBytes())
        );
    }
    return super.shouldInterceptRequest(view, request);
}

private static boolean isImage(String url, Resources res) {
        BufferedReader imageUrlRegex = openRawFile(res, R.raw.image_regex);
        try {
            String line = imageUrlRegex.readLine();
            while (line != null) {
                Pattern pattern = Pattern.compile(line);
                if (pattern.matcher(url).find())
                    return true;
                line = imageUrlRegex.readLine();
            }
        } catch (IOException e) {
            e.printStackTrace();
            return true;
        }
        return false;
    }

data:image/(jpg|png|jpeg|svg|ico|webp|tif|tiff|bmp|eps|apng|avif|jfif|pjpeg|pjp|cur);base64,

**note : I tried block like this return url.contains("data:image"); still nothing

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!