mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-02-24 14:51:05 +01:00
strip html
This commit is contained in:
parent
a26a13a88d
commit
193fc349f0
1 changed files with 11 additions and 0 deletions
11
lnbits/db.py
11
lnbits/db.py
|
@ -1,6 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
@ -71,6 +72,16 @@ class Connection(Compat):
|
||||||
if self.type in {POSTGRES, COCKROACH}:
|
if self.type in {POSTGRES, COCKROACH}:
|
||||||
query = query.replace("%", "%%")
|
query = query.replace("%", "%%")
|
||||||
query = query.replace("?", "%s")
|
query = query.replace("?", "%s")
|
||||||
|
|
||||||
|
# strip html
|
||||||
|
CLEANR = re.compile("<.*?>|&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});")
|
||||||
|
|
||||||
|
def cleanhtml(raw_html):
|
||||||
|
cleantext = re.sub(CLEANR, "", raw_html)
|
||||||
|
return cleantext
|
||||||
|
|
||||||
|
query = cleanhtml(query)
|
||||||
|
|
||||||
return query
|
return query
|
||||||
|
|
||||||
async def fetchall(self, query: str, values: tuple = ()) -> list:
|
async def fetchall(self, query: str, values: tuple = ()) -> list:
|
||||||
|
|
Loading…
Add table
Reference in a new issue