Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip characters from stdbounties_id and check isdigit #1973

Merged
merged 1 commit into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/app/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import email
import imaplib
import logging
import re
import time

from django.conf import settings
Expand Down Expand Up @@ -278,3 +279,8 @@ def get_country_from_ip(ip_address, db=None):
logger.warning(f'Encountered ({e}) while attempting to retrieve a user\'s geolocation')

return country


def clean_str(string):
"""Clean the provided string of all non-alpha numeric characters."""
return re.sub(r'\W+', '', string)
5 changes: 3 additions & 2 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_GET, require_POST

from app.utils import ellipses, sync_profile
from app.utils import clean_str, ellipses, sync_profile
from avatar.utils import get_avatar_context
from economy.utils import convert_amount
from gas.utils import conf_time_spread, gas_advisories, gas_history, recommend_min_gas_price_to_confirm_in_time
Expand Down Expand Up @@ -928,7 +928,8 @@ def bounty_details(request, ghuser='', ghrepo='', ghissue=0, stdbounties_id=None
if issue_url:
try:
bounties = Bounty.objects.current().filter(github_url=issue_url)
if stdbounties_id:
stdbounties_id = clean_str(stdbounties_id)
if stdbounties_id and stdbounties_id.isdigit():
bounties = bounties.filter(standard_bounties_id=stdbounties_id)
if bounties:
bounty = bounties.order_by('-pk').first()
Expand Down