pull/208/head
parent
249a9e685f
commit
f35f495b17
|
@ -279,6 +279,8 @@ reddit_s_url_regex = re.compile("https:\/\/reddit.com\/[ru]\/\w{2,25}\/s\/\w{10}
|
|||
#run-time
|
||||
reddit_to_vreddit_regex = re.compile('(^|>|")https:\/\/old.reddit.com\/(r|user)\/', flags=re.A)
|
||||
|
||||
#post search
|
||||
subreddit_name_regex = re.compile('\w{2,25}', flags=re.A)
|
||||
|
||||
|
||||
###YOUTUBE
|
||||
|
|
|
@ -22,6 +22,7 @@ valid_params = [
|
|||
'title',
|
||||
'sentto',
|
||||
search_operator_hole,
|
||||
'subreddit',
|
||||
]
|
||||
|
||||
def searchparse(text):
|
||||
|
@ -129,6 +130,15 @@ def searchposts(v):
|
|||
)
|
||||
)
|
||||
|
||||
if 'subreddit' in criteria:
|
||||
subreddit = criteria['subreddit']
|
||||
|
||||
if not subreddit_name_regex.fullmatch(subreddit):
|
||||
abort(400, "Invalid subreddit name.")
|
||||
|
||||
posts = posts.filter(Post.url.ilike(f"https://old.reddit.com/r/{subreddit}/%"))
|
||||
|
||||
|
||||
if search_operator_hole in criteria:
|
||||
posts = posts.filter(Post.sub == criteria[search_operator_hole])
|
||||
|
||||
|
|
|
@ -77,6 +77,10 @@
|
|||
<div style="display: inline-block; width: 150px; text-align: center">Exact Match Only:</div>
|
||||
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam(this, 'bool')" class="searchparam mb-1">exact:true</button>
|
||||
</div>
|
||||
<div>
|
||||
<div style="display: inline-block; width: 150px; text-align: center">Subreddit:</div>
|
||||
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam(this)" class="searchparam mb-1">subreddit:menslib</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if FEATURES['NSFW_MARKING'] %}
|
||||
<div>
|
||||
|
|
Loading…
Reference in New Issue