Example #1
0
def create_issue():
    # copy the form so we can add the full UA string to it.
    form = request.form.copy()
    form['ua_header'] = request.headers.get('User-Agent')
    if form.get('submit-type') == AUTH_REPORT:
        if g.user:  # If you're already authed, submit the bug.
            response = report_issue(form)
            return thanks_page(request, response)
        else:  # Stash form data into session, go do GitHub auth
            session['form_data'] = form
            return redirect(url_for('login'))
    elif form.get('submit-type') == PROXY_REPORT:
        response = report_issue(form, proxy=True).json()
        return thanks_page(request, response)
Example #2
0
def create_issue():
    # copy the form so we can add the full UA string to it.
    form = request.form.copy()
    form['ua_header'] = request.headers.get('User-Agent')
    # Do we have an image or screenshot ready to be uploaded?
    if ((request.files['image'] and request.files['image'].filename) or
       request.form.get('screenshot')):
        form['image_upload'] = json.loads(upload()[0])
    if form.get('submit-type') == AUTH_REPORT:
        if g.user:  # If you're already authed, submit the bug.
            response = report_issue(form)
            return thanks_page(request, response)
        else:  # Stash form data into session, go do GitHub auth
            session['form_data'] = form
            return redirect(url_for('login'))
    elif form.get('submit-type') == PROXY_REPORT:
        response = report_issue(form, proxy=True).json()
        return thanks_page(request, response)
Example #3
0
def create_issue():
    # copy the form so we can add the full UA string to it.
    form = request.form.copy()
    form['ua_header'] = request.headers.get('User-Agent')
    # Do we have an image or screenshot ready to be uploaded?
    if ((request.files['image'] and request.files['image'].filename)
            or request.form.get('screenshot')):
        form['image_upload'] = json.loads(upload()[0])
    if form.get('submit-type') == AUTH_REPORT:
        if g.user:  # If you're already authed, submit the bug.
            response = report_issue(form)
            return thanks_page(request, response)
        else:  # Stash form data into session, go do GitHub auth
            session['form_data'] = form
            return redirect(url_for('login'))
    elif form.get('submit-type') == PROXY_REPORT:
        response = report_issue(form, proxy=True).json()
        return thanks_page(request, response)
Example #4
0
def create_issue():
    """Creates a new issue.

    GET will return an HTML response for reporting issues
    POST will create a new issue
    """
    if request.method == "GET":
        bug_form = get_form(request.headers.get("User-Agent"))
        if g.user:
            get_user_info()
        return render_template("new-issue.html", form=bug_form)
    # copy the form so we can add the full UA string to it.
    form = request.form.copy()
    # see https://github.com/webcompat/webcompat.com/issues/1141
    spamlist = ["qiangpiaoruanjian"]
    for spam in spamlist:
        if spam in form.get("url"):
            msg = (
                u"Anonymous reporting for qiangpiaoruanjian.cn "
                "is temporarily disabled. Please see "
                "https://github.com/webcompat/webcompat.com/issues/1141 "
                "for more details."
            )
            flash(msg, "notimeout")
            return redirect(url_for("index"))
    form["ua_header"] = request.headers.get("User-Agent")
    # Store where the report originated from
    form["reported_with"] = request.headers.get("X-Reported-With", "web")
    # Logging the ip and url for investigation
    log = app.logger
    log.setLevel(logging.INFO)
    log.info("{ip} {url}".format(ip=request.remote_addr, url=form["url"]))
    # form submission for 3 scenarios: authed, to be authed, anonymous
    if form.get("submit-type") == AUTH_REPORT:
        if g.user:  # If you're already authed, submit the bug.
            response = report_issue(form)
            return thanks_page(request, response)
        else:  # Stash form data into session, go do GitHub auth
            session["form_data"] = form
            return redirect(url_for("login"))
    elif form.get("submit-type") == PROXY_REPORT:
        response = report_issue(form, proxy=True).json()
        return thanks_page(request, response)
Example #5
0
def create_issue():
    # copy the form so we can add the full UA string to it.
    form = request.form.copy()
    form['ua_header'] = request.headers.get('User-Agent')
    # Logging the ip and url for investigation
    log = app.logger
    log.setLevel(logging.INFO)
    log.info('{ip} {url}'.format(ip=request.remote_addr, url=form['url']))
    # form submission for 3 scenarios: authed, to be authed, anonymous
    if form.get('submit-type') == AUTH_REPORT:
        if g.user:  # If you're already authed, submit the bug.
            response = report_issue(form)
            return thanks_page(request, response)
        else:  # Stash form data into session, go do GitHub auth
            session['form_data'] = form
            return redirect(url_for('login'))
    elif form.get('submit-type') == PROXY_REPORT:
        response = report_issue(form, proxy=True).json()
        return thanks_page(request, response)
Example #6
0
def create_issue():
    """Creates a new issue.

    GET will return an HTML response for reporting issues
    POST will create a new issue
    """
    if request.method == 'GET':
        bug_form = get_form(request.headers.get('User-Agent'))
        if g.user:
            get_user_info()
        return render_template('new-issue.html', form=bug_form)
    # copy the form so we can add the full UA string to it.
    form = request.form.copy()
    # see https://github.com/webcompat/webcompat.com/issues/1141
    spamlist = ['qiangpiaoruanjian']
    for spam in spamlist:
        if spam in form.get('url'):
            msg = (u'Anonymous reporting for qiangpiaoruanjian.cn '
                   'is temporarily disabled. Please see '
                   'https://github.com/webcompat/webcompat.com/issues/1141 '
                   'for more details.')
            flash(msg, 'notimeout')
            return redirect(url_for('index'))
    form['ua_header'] = request.headers.get('User-Agent')
    # Store where the report originated from
    form['reported_with'] = request.headers.get('X-Reported-With', 'web')
    # Logging the ip and url for investigation
    log = app.logger
    log.setLevel(logging.INFO)
    log.info('{ip} {url}'.format(ip=request.remote_addr, url=form['url']))
    # form submission for 3 scenarios: authed, to be authed, anonymous
    if form.get('submit-type') == AUTH_REPORT:
        if g.user:  # If you're already authed, submit the bug.
            response = report_issue(form)
            return thanks_page(request, response)
        else:  # Stash form data into session, go do GitHub auth
            session['form_data'] = form
            return redirect(url_for('login'))
    elif form.get('submit-type') == PROXY_REPORT:
        response = report_issue(form, proxy=True).json()
        return thanks_page(request, response)