php - How to remove a data uri from text using a regular expression? -


What is a great way to remove data URI from a block of text with regular expression ? My application has to be removed from email body texts because Amazon SES (Simple Email Service) rejects any email with data URI. . They should also be removed for security purposes

Example data URI:

  data: image / gif; Base 64, R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o / XBs / fNwfjZ0frl3 / zy7 //// wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7   

It can be surrounded by quotes such as HTML:

  & lt ; img src = "data: image / gif; base64, R0lGODlhEAAQA ...." / & gt;   

Or this can be a CSS background:

  Background: URL (Data: Image / GIF; Base64, RLGODLAAAAAAAAA ... .);    

This should do the trick:

  $ Regex = '~ Data: [^;] +; [E-za-j 0-9] +, [^] \ '\ s] + ~'; $ Body = preg_replace ($ regex, '', $ body);    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -