requested changes
This commit is contained in:
parent
abdc7df11b
commit
2514c7b2a8
|
@ -13,7 +13,7 @@ from app.models.config import Config
|
||||||
from app.request import Request, TorError
|
from app.request import Request, TorError
|
||||||
from app.utils.bangs import resolve_bang
|
from app.utils.bangs import resolve_bang
|
||||||
from app.utils.misc import read_config_bool
|
from app.utils.misc import read_config_bool
|
||||||
from app.utils.results import add_ip
|
from app.utils.results import add_ip_card
|
||||||
from app.utils.search import *
|
from app.utils.search import *
|
||||||
from app.utils.session import generate_user_key, valid_user_session
|
from app.utils.session import generate_user_key, valid_user_session
|
||||||
from bs4 import BeautifulSoup as bsoup
|
from bs4 import BeautifulSoup as bsoup
|
||||||
|
@ -254,7 +254,7 @@ def search():
|
||||||
# Feature to display IP address
|
# Feature to display IP address
|
||||||
if search_util.check_kw_ip():
|
if search_util.check_kw_ip():
|
||||||
html_soup = bsoup(response, "html.parser")
|
html_soup = bsoup(response, "html.parser")
|
||||||
response = add_ip(html_soup, request.remote_addr)
|
response = add_ip_card(html_soup, request.remote_addr)
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'display.html',
|
'display.html',
|
||||||
|
|
|
@ -32,10 +32,10 @@ details summary {
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ip-address-div{
|
.ip-address-div {
|
||||||
padding-bottom:0!important;
|
padding-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ip-text-div{
|
.ip-text-div {
|
||||||
padding-top:0!important;
|
padding-top: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ def append_nojs(result: BeautifulSoup) -> None:
|
||||||
result.append(nojs_link)
|
result.append(nojs_link)
|
||||||
|
|
||||||
|
|
||||||
def add_ip(html_soup: BeautifulSoup, ip: str) -> BeautifulSoup:
|
def add_ip_card(html_soup: BeautifulSoup, ip: str) -> BeautifulSoup:
|
||||||
"""Adds the client's IP address to the search results
|
"""Adds the client's IP address to the search results
|
||||||
if query contains keywords
|
if query contains keywords
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
import os
|
import os
|
||||||
from typing import Any
|
|
||||||
import re
|
import re
|
||||||
|
from typing import Any
|
||||||
from bs4 import BeautifulSoup as bsoup
|
|
||||||
from cryptography.fernet import Fernet, InvalidToken
|
|
||||||
from flask import g
|
|
||||||
|
|
||||||
from app.filter import Filter, get_first_link
|
from app.filter import Filter, get_first_link
|
||||||
from app.request import gen_query
|
from app.request import gen_query
|
||||||
|
from bs4 import BeautifulSoup as bsoup
|
||||||
|
from cryptography.fernet import Fernet, InvalidToken
|
||||||
|
from flask import g
|
||||||
|
|
||||||
TOR_BANNER = '<hr><h1 style="text-align: center">You are using Tor</h1><hr>'
|
TOR_BANNER = '<hr><h1 style="text-align: center">You are using Tor</h1><hr>'
|
||||||
CAPTCHA = 'div class="g-recaptcha"'
|
CAPTCHA = 'div class="g-recaptcha"'
|
||||||
|
@ -55,6 +54,7 @@ class Search:
|
||||||
config: the current user config settings
|
config: the current user config settings
|
||||||
session: the flask user session
|
session: the flask user session
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, request, config, session, cookies_disabled=False):
|
def __init__(self, request, config, session, cookies_disabled=False):
|
||||||
method = request.method
|
method = request.method
|
||||||
self.request_params = request.args if method == 'GET' else request.form
|
self.request_params = request.args if method == 'GET' else request.form
|
||||||
|
@ -163,15 +163,13 @@ class Search:
|
||||||
|
|
||||||
return str(formatted_results)
|
return str(formatted_results)
|
||||||
|
|
||||||
def check_kw_ip(self) -> bool:
|
def check_kw_ip(self) -> re.Match:
|
||||||
"""Checks for keywords related to 'my ip' in the query
|
"""Checks for keywords related to 'my ip' in the query
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool
|
bool
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if re.search("([^a-z0-9]|^)my *[^a-z0-9] *(ip|internet protocol)" +
|
return re.search("([^a-z0-9]|^)my *[^a-z0-9] *(ip|internet protocol)" +
|
||||||
"($|( *[^a-z0-9] *(((addres|address|adres|adress)|a)?" +
|
"($|( *[^a-z0-9] *(((addres|address|adres|adress)|a)?" +
|
||||||
" *$)))", self.query.lower()):
|
" *$)))", self.query.lower())
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user