How to convert SQL in mysql binlog to html?

156 Views Asked by At

My site was hacked and I was able to retrieve some SQL from binlog, they look like

<p>some text</p>\r\n<p><img src=\"images/2019-04-27/1.jpg\" alt=\"1\" /></p>

I need to convert \r\n to new line and unescape the double quotes. Of course I can write my own function to achieve this, but since there are lots of SQLs to convert, I am not sure if \r\n and \" are the only things I need to deal with.

I think the key here is to find out what this conversion is called so I can google. I tried "html encode", "html escape" and "sql escape", none of them worked.

So, is there any PHP or JAVASCRIPT function that can handle this? Or is there any online tools?

1

There are 1 best solutions below

0
Ryan Davies On

Python automatically converts /n into a new line for you. For example, if you go onto this website here - www.repl.it/languages/python3

string = '<p>some text</p>\r\n<p><img src=\"images/2019-04-27/1.jpg\" alt=\"1\" /></p>'

print(string)

Copy the above code into it and you'll see the string is given a new line

If you need to use a multi line string put the string in 3 quotation marks like so.

string = '''
I
am
a 
multi
line
string
'''