prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Replace all 3rd party links to reliable resource
  **Describe the bug**
  Many links which have either been used for testing/mainstream access  using `urllib` are often blocked due to some issue with the site security or some other reason. 
  
  **Expected behavior**
  All links must point to a certain reliable resource like FOSSASIA's website to ensure reliable access.
  
  **Stacktrace**
  One of the plausible errors which might occur `urllib.error.HTTPError: HTTP Error 403: Forbidden`
  
  **Additional Info**:
  Working  on it
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `app/api/helpers/utilities.py`
  Content:
  ```
  1 # PLEASE PUT ALL FUNCTIONS WHICH PERFORM GENERAL FORMATTING ON ANY DATATYPE WITHOUT USING ANY
  2 # MODULES RELATED TO THE EVENT-SYSTEM i.e FUNCTIONS SPECIFIC TO DB MODELS E.G A FUNCTION JUST FOR ROLE_INVITES
  3 import random
  4 import string
  5 import sys
  6 
  7 import bleach
  8 from itsdangerous import Serializer
  9 import requests
  10 import re
  11 
  12 from app.api.helpers.exceptions import UnprocessableEntity
  13 
  14 from flask import current_app
  15 
  16 
  17 def dasherize(text):
  18     return text.replace('_', '-')
  19 
  20 
  21 def require_relationship(resource_list, data):
  22     for resource in resource_list:
  23         if resource not in data:
  24             raise UnprocessableEntity({'pointer': '/data/relationships/{}'.format(resource)},
  25                                       "A valid relationship with {} resource is required".format(resource))
  26 
  27 
  28 def string_empty(value):
  29     is_not_str_type = type(value) is not str
  30     if sys.version_info[0] < 3:
  31         is_not_str_type = is_not_str_type and type(value) is not unicode
  32     if type(value) is not value and is_not_str_type:
  33         return False
  34     return not (value and value.strip() and value != u'' and value != u' ')
  35 
  36 
  37 def strip_tags(html):
  38     if html is None:
  39         return None
  40     return bleach.clean(html, tags=[], attributes={}, styles=[], strip=True)
  41 
  42 
  43 def get_serializer(secret_key='secret_key'):
  44     return Serializer(secret_key)
  45 
  46 
  47 def str_generator(size=6, chars=string.ascii_uppercase + string.digits):
  48     return ''.join(random.choice(chars) for _ in range(size))
  49 
  50 
  51 # From http://stackoverflow.com/a/3425124
  52 def monthdelta(date, delta):
  53     m, y = (date.month + delta) % 12, date.year + (date.month + delta - 1) // 12
  54     if not m:
  55         m = 12
  56     d = min(date.day, [31,
  57                        29 if y % 4 == 0 and not y % 400 == 0 else 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m - 1])
  58     return date.replace(day=d, month=m, year=y)
  59 
  60 
  61 def represents_int(value):
  62     try:
  63         int(value)
  64         return True
  65     except:
  66         return False
  67 
  68 
  69 def is_downloadable(url):
  70     """
  71     Does the url contain a downloadable resource
  72     """
  73     h = requests.head(url, allow_redirects=True)
  74     header = h.headers
  75     content_type = header.get('content-type')
  76     # content_length = header.get('content-length', 1e10)
  77     if 'text' in content_type.lower():
  78         return False
  79     if 'html' in content_type.lower():
  80         return False
  81     return True
  82 
  83 
  84 def get_filename_from_cd(cd):
  85     """
  86     Get filename and ext from content-disposition
  87     """
  88     if not cd:
  89         return '', ''
  90     fname = re.findall('filename=(.+)', cd)
  91     if len(fname) == 0:
  92         return '', ''
  93     fn = fname[0].rsplit('.', 1)
  94     return fn[0], '' if len(fn) == 1 else ('.' + fn[1])
  95 
  96 
  97 def write_file(file, data):
  98     """simple write to file"""
  99     fp = open(file, 'w')
  100     fp.write(str(data, 'utf-8'))
  101     fp.close()
  102 
  103 
  104 def update_state(task_handle, state, result=None):
  105     """
  106     Update state of celery task
  107     """
  108     if result is None:
  109         result = {}
  110     if not current_app.config.get('CELERY_ALWAYS_EAGER'):
  111         task_handle.update_state(
  112             state=state, meta=result
  113         )
  114 
  115 
  116 # store task results in case of testing
  117 # state and info
  118 TASK_RESULTS = {}
  119 
  120 
  121 class EmptyObject(object):
  122     pass
  123
  ```
  
  Path: `app/factories/common.py`
  Content:
  ```
  1 import factory
  2 
  3 # use camelCase for naming variables
  4 
  5 string_ = 'example'
  6 email_ = factory.Sequence(lambda n: 'user{0}@example.com'.format(n))
  7 integer_ = 25
  8 url_ = 'http://example.com'
  9 imageUrl_ = 'https://www.w3schools.com/html/pic_mountain.jpg'
  10 date_ = '2016-12-13T23:59:59.123456+00:00'
  11 dateFuture_ = '2099-12-13T23:59:59.123456+00:00'
  12 dateEndFuture_ = '2099-12-14T23:59:59.123456+00:00'
  13 dateEnd_ = '2020-12-14T23:59:59.123456+00:00'
  14 country_ = 'US'
  15 currency_ = 'USD'
  16 int_ = '1'
  17 float_ = '1.23456789'
  18 timezone_ = 'UTC'
  19 environment_ = 'production'
  20 secret_ = 'ABCDefghIJKLmnop'
  21 fee_ = '1.23'
  22 slug_ = factory.Sequence(lambda n: 'example_slug{0}'.format(n))
  23 
  24 
  25 def socialUrl_(name):
  26     return 'https://{}.com/{}'.format(name, name)
  27
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/app/api/helpers/utilities.py b/app/api/helpers/utilities.py
  --- a/app/api/helpers/utilities.py
  +++ b/app/api/helpers/utilities.py
  @@ -112,6 +112,8 @@
               state=state, meta=result
           )
   
  +static_page = 'https://eventyay.com/'
  +image_link = 'https://www.gstatic.com/webp/gallery/1.jpg'
   
   # store task results in case of testing
   # state and info
  diff --git a/app/factories/common.py b/app/factories/common.py
  --- a/app/factories/common.py
  +++ b/app/factories/common.py
  @@ -1,12 +1,12 @@
   import factory
  -
  +from app.api.helpers.utilities import static_page, image_link
   # use camelCase for naming variables
   
   string_ = 'example'
   email_ = factory.Sequence(lambda n: 'user{0}@example.com'.format(n))
   integer_ = 25
  -url_ = 'http://example.com'
  -imageUrl_ = 'https://www.w3schools.com/html/pic_mountain.jpg'
  +url_ = static_page
  +imageUrl_ = image_link
   date_ = '2016-12-13T23:59:59.123456+00:00'
   dateFuture_ = '2099-12-13T23:59:59.123456+00:00'
   dateEndFuture_ = '2099-12-14T23:59:59.123456+00:00'
  
verification_info: {"golden_diff": "diff --git a/app/api/helpers/utilities.py b/app/api/helpers/utilities.py\n--- a/app/api/helpers/utilities.py\n+++ b/app/api/helpers/utilities.py\n@@ -112,6 +112,8 @@\n             state=state, meta=result\n         )\n \n+static_page = 'https://eventyay.com/'\n+image_link = 'https://www.gstatic.com/webp/gallery/1.jpg'\n \n # store task results in case of testing\n # state and info\ndiff --git a/app/factories/common.py b/app/factories/common.py\n--- a/app/factories/common.py\n+++ b/app/factories/common.py\n@@ -1,12 +1,12 @@\n import factory\n-\n+from app.api.helpers.utilities import static_page, image_link\n # use camelCase for naming variables\n \n string_ = 'example'\n email_ = factory.Sequence(lambda n: 'user{0}@example.com'.format(n))\n integer_ = 25\n-url_ = 'http://example.com'\n-imageUrl_ = 'https://www.w3schools.com/html/pic_mountain.jpg'\n+url_ = static_page\n+imageUrl_ = image_link\n date_ = '2016-12-13T23:59:59.123456+00:00'\n dateFuture_ = '2099-12-13T23:59:59.123456+00:00'\n dateEndFuture_ = '2099-12-14T23:59:59.123456+00:00'\n", "issue": "Replace all 3rd party links to reliable resource\n**Describe the bug**\r\nMany links which have either been used for testing/mainstream access  using `urllib` are often blocked due to some issue with the site security or some other reason. \r\n\r\n**Expected behavior**\r\nAll links must point to a certain reliable resource like FOSSASIA's website to ensure reliable access.\r\n\r\n**Stacktrace**\r\nOne of the plausible errors which might occur `urllib.error.HTTPError: HTTP Error 403: Forbidden`\r\n\r\n**Additional Info**:\r\nWorking  on it\n", "before_files": [{"content": "# PLEASE PUT ALL FUNCTIONS WHICH PERFORM GENERAL FORMATTING ON ANY DATATYPE WITHOUT USING ANY\n# MODULES RELATED TO THE EVENT-SYSTEM i.e FUNCTIONS SPECIFIC TO DB MODELS E.G A FUNCTION JUST FOR ROLE_INVITES\nimport random\nimport string\nimport sys\n\nimport bleach\nfrom itsdangerous import Serializer\nimport requests\nimport re\n\nfrom app.api.helpers.exceptions import UnprocessableEntity\n\nfrom flask import current_app\n\n\ndef dasherize(text):\n    return text.replace('_', '-')\n\n\ndef require_relationship(resource_list, data):\n    for resource in resource_list:\n        if resource not in data:\n            raise UnprocessableEntity({'pointer': '/data/relationships/{}'.format(resource)},\n                                      \"A valid relationship with {} resource is required\".format(resource))\n\n\ndef string_empty(value):\n    is_not_str_type = type(value) is not str\n    if sys.version_info[0] < 3:\n        is_not_str_type = is_not_str_type and type(value) is not unicode\n    if type(value) is not value and is_not_str_type:\n        return False\n    return not (value and value.strip() and value != u'' and value != u' ')\n\n\ndef strip_tags(html):\n    if html is None:\n        return None\n    return bleach.clean(html, tags=[], attributes={}, styles=[], strip=True)\n\n\ndef get_serializer(secret_key='secret_key'):\n    return Serializer(secret_key)\n\n\ndef str_generator(size=6, chars=string.ascii_uppercase + string.digits):\n    return ''.join(random.choice(chars) for _ in range(size))\n\n\n# From http://stackoverflow.com/a/3425124\ndef monthdelta(date, delta):\n    m, y = (date.month + delta) % 12, date.year + (date.month + delta - 1) // 12\n    if not m:\n        m = 12\n    d = min(date.day, [31,\n                       29 if y % 4 == 0 and not y % 400 == 0 else 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m - 1])\n    return date.replace(day=d, month=m, year=y)\n\n\ndef represents_int(value):\n    try:\n        int(value)\n        return True\n    except:\n        return False\n\n\ndef is_downloadable(url):\n    \"\"\"\n    Does the url contain a downloadable resource\n    \"\"\"\n    h = requests.head(url, allow_redirects=True)\n    header = h.headers\n    content_type = header.get('content-type')\n    # content_length = header.get('content-length', 1e10)\n    if 'text' in content_type.lower():\n        return False\n    if 'html' in content_type.lower():\n        return False\n    return True\n\n\ndef get_filename_from_cd(cd):\n    \"\"\"\n    Get filename and ext from content-disposition\n    \"\"\"\n    if not cd:\n        return '', ''\n    fname = re.findall('filename=(.+)', cd)\n    if len(fname) == 0:\n        return '', ''\n    fn = fname[0].rsplit('.', 1)\n    return fn[0], '' if len(fn) == 1 else ('.' + fn[1])\n\n\ndef write_file(file, data):\n    \"\"\"simple write to file\"\"\"\n    fp = open(file, 'w')\n    fp.write(str(data, 'utf-8'))\n    fp.close()\n\n\ndef update_state(task_handle, state, result=None):\n    \"\"\"\n    Update state of celery task\n    \"\"\"\n    if result is None:\n        result = {}\n    if not current_app.config.get('CELERY_ALWAYS_EAGER'):\n        task_handle.update_state(\n            state=state, meta=result\n        )\n\n\n# store task results in case of testing\n# state and info\nTASK_RESULTS = {}\n\n\nclass EmptyObject(object):\n    pass\n", "path": "app/api/helpers/utilities.py"}, {"content": "import factory\n\n# use camelCase for naming variables\n\nstring_ = 'example'\nemail_ = factory.Sequence(lambda n: 'user{0}@example.com'.format(n))\ninteger_ = 25\nurl_ = 'http://example.com'\nimageUrl_ = 'https://www.w3schools.com/html/pic_mountain.jpg'\ndate_ = '2016-12-13T23:59:59.123456+00:00'\ndateFuture_ = '2099-12-13T23:59:59.123456+00:00'\ndateEndFuture_ = '2099-12-14T23:59:59.123456+00:00'\ndateEnd_ = '2020-12-14T23:59:59.123456+00:00'\ncountry_ = 'US'\ncurrency_ = 'USD'\nint_ = '1'\nfloat_ = '1.23456789'\ntimezone_ = 'UTC'\nenvironment_ = 'production'\nsecret_ = 'ABCDefghIJKLmnop'\nfee_ = '1.23'\nslug_ = factory.Sequence(lambda n: 'example_slug{0}'.format(n))\n\n\ndef socialUrl_(name):\n    return 'https://{}.com/{}'.format(name, name)\n", "path": "app/factories/common.py"}], "after_files": [{"content": "# PLEASE PUT ALL FUNCTIONS WHICH PERFORM GENERAL FORMATTING ON ANY DATATYPE WITHOUT USING ANY\n# MODULES RELATED TO THE EVENT-SYSTEM i.e FUNCTIONS SPECIFIC TO DB MODELS E.G A FUNCTION JUST FOR ROLE_INVITES\nimport random\nimport string\nimport sys\n\nimport bleach\nfrom itsdangerous import Serializer\nimport requests\nimport re\n\nfrom app.api.helpers.exceptions import UnprocessableEntity\n\nfrom flask import current_app\n\n\ndef dasherize(text):\n    return text.replace('_', '-')\n\n\ndef require_relationship(resource_list, data):\n    for resource in resource_list:\n        if resource not in data:\n            raise UnprocessableEntity({'pointer': '/data/relationships/{}'.format(resource)},\n                                      \"A valid relationship with {} resource is required\".format(resource))\n\n\ndef string_empty(value):\n    is_not_str_type = type(value) is not str\n    if sys.version_info[0] < 3:\n        is_not_str_type = is_not_str_type and type(value) is not unicode\n    if type(value) is not value and is_not_str_type:\n        return False\n    return not (value and value.strip() and value != u'' and value != u' ')\n\n\ndef strip_tags(html):\n    if html is None:\n        return None\n    return bleach.clean(html, tags=[], attributes={}, styles=[], strip=True)\n\n\ndef get_serializer(secret_key='secret_key'):\n    return Serializer(secret_key)\n\n\ndef str_generator(size=6, chars=string.ascii_uppercase + string.digits):\n    return ''.join(random.choice(chars) for _ in range(size))\n\n\n# From http://stackoverflow.com/a/3425124\ndef monthdelta(date, delta):\n    m, y = (date.month + delta) % 12, date.year + (date.month + delta - 1) // 12\n    if not m:\n        m = 12\n    d = min(date.day, [31,\n                       29 if y % 4 == 0 and not y % 400 == 0 else 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m - 1])\n    return date.replace(day=d, month=m, year=y)\n\n\ndef represents_int(value):\n    try:\n        int(value)\n        return True\n    except:\n        return False\n\n\ndef is_downloadable(url):\n    \"\"\"\n    Does the url contain a downloadable resource\n    \"\"\"\n    h = requests.head(url, allow_redirects=True)\n    header = h.headers\n    content_type = header.get('content-type')\n    # content_length = header.get('content-length', 1e10)\n    if 'text' in content_type.lower():\n        return False\n    if 'html' in content_type.lower():\n        return False\n    return True\n\n\ndef get_filename_from_cd(cd):\n    \"\"\"\n    Get filename and ext from content-disposition\n    \"\"\"\n    if not cd:\n        return '', ''\n    fname = re.findall('filename=(.+)', cd)\n    if len(fname) == 0:\n        return '', ''\n    fn = fname[0].rsplit('.', 1)\n    return fn[0], '' if len(fn) == 1 else ('.' + fn[1])\n\n\ndef write_file(file, data):\n    \"\"\"simple write to file\"\"\"\n    fp = open(file, 'w')\n    fp.write(str(data, 'utf-8'))\n    fp.close()\n\n\ndef update_state(task_handle, state, result=None):\n    \"\"\"\n    Update state of celery task\n    \"\"\"\n    if result is None:\n        result = {}\n    if not current_app.config.get('CELERY_ALWAYS_EAGER'):\n        task_handle.update_state(\n            state=state, meta=result\n        )\n\nstatic_page = 'https://eventyay.com/'\nimage_link = 'https://www.gstatic.com/webp/gallery/1.jpg'\n\n# store task results in case of testing\n# state and info\nTASK_RESULTS = {}\n\n\nclass EmptyObject(object):\n    pass\n", "path": "app/api/helpers/utilities.py"}, {"content": "import factory\nfrom app.api.helpers.utilities import static_page, image_link\n# use camelCase for naming variables\n\nstring_ = 'example'\nemail_ = factory.Sequence(lambda n: 'user{0}@example.com'.format(n))\ninteger_ = 25\nurl_ = static_page\nimageUrl_ = image_link\ndate_ = '2016-12-13T23:59:59.123456+00:00'\ndateFuture_ = '2099-12-13T23:59:59.123456+00:00'\ndateEndFuture_ = '2099-12-14T23:59:59.123456+00:00'\ndateEnd_ = '2020-12-14T23:59:59.123456+00:00'\ncountry_ = 'US'\ncurrency_ = 'USD'\nint_ = '1'\nfloat_ = '1.23456789'\ntimezone_ = 'UTC'\nenvironment_ = 'production'\nsecret_ = 'ABCDefghIJKLmnop'\nfee_ = '1.23'\nslug_ = factory.Sequence(lambda n: 'example_slug{0}'.format(n))\n\n\ndef socialUrl_(name):\n    return 'https://{}.com/{}'.format(name, name)\n", "path": "app/factories/common.py"}]}