Internal Server Error 7.1.3

We have had the same problem after upgrading from 7.0.5.

The exception is caused by the programming in seahub/views/repo.py, method view_shared_dir:

def view_shared_dir(request, fileshare):

    token = fileshare.token

    password_check_passed, err_msg = check_share_link_common(request, fileshare)
    if not password_check_passed:
        d = {'token': token, 'view_name': 'view_shared_dir', 'err_msg': err_msg}
        return render(request, 'share_access_validation.html', d)

    username = fileshare.username
    repo_id = fileshare.repo_id

    # Get path from frontend, use '/' if missing, and construct request path
    # with fileshare.path to real path, used to fetch dirents by RPC.
    req_path = request.GET.get('p', '/')
    if req_path[-1] != '/':  
        req_path += '/'

If a password is required, the data for the html template contains no path field, so
req_path is an empty string and req_path[-1] crashes.

Solutions:

  1. delete the path form variable from the template
    or
  2. check req_path for an empty string, i.e.
# Get path from frontend, use '/' if missing, and construct request path  
# with fileshare.path to real path, used to fetch dirents by RPC.
req_path = request.GET.get('p', '/')
if req_path=="" or req_path[-1] != '/':
    req_path += '/'
5 Likes