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.utils.bangs import resolve_bang
|
||||
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.session import generate_user_key, valid_user_session
|
||||
from bs4 import BeautifulSoup as bsoup
|
||||
|
@ -254,7 +254,7 @@ def search():
|
|||
# Feature to display IP address
|
||||
if search_util.check_kw_ip():
|
||||
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(
|
||||
'display.html',
|
||||
|
|
|
@ -32,10 +32,10 @@ details summary {
|
|||
border: 0;
|
||||
}
|
||||
|
||||
.ip-address-div{
|
||||
padding-bottom:0!important;
|
||||
.ip-address-div {
|
||||
padding-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.ip-text-div{
|
||||
padding-top:0!important;
|
||||
.ip-text-div {
|
||||
padding-top: 0 !important;
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ def append_nojs(result: BeautifulSoup) -> None:
|
|||
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
|
||||
if query contains keywords
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import os
|
||||
from typing import Any
|
||||
import re
|
||||
|
||||
from bs4 import BeautifulSoup as bsoup
|
||||
from cryptography.fernet import Fernet, InvalidToken
|
||||
from flask import g
|
||||
from typing import Any
|
||||
|
||||
from app.filter import Filter, get_first_link
|
||||
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>'
|
||||
CAPTCHA = 'div class="g-recaptcha"'
|
||||
|
@ -55,6 +54,7 @@ class Search:
|
|||
config: the current user config settings
|
||||
session: the flask user session
|
||||
"""
|
||||
|
||||
def __init__(self, request, config, session, cookies_disabled=False):
|
||||
method = request.method
|
||||
self.request_params = request.args if method == 'GET' else request.form
|
||||
|
@ -163,15 +163,13 @@ class Search:
|
|||
|
||||
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
|
||||
|
||||
Returns:
|
||||
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)?" +
|
||||
" *$)))", self.query.lower()):
|
||||
return True
|
||||
return False
|
||||
" *$)))", self.query.lower())
|
||||
|
|
Loading…
Reference in New Issue
Block a user