<commit_before>import os
import subprocess
from flask import Flask, abort, make_response, jsonify, request
from urllib.parse import urlparse
import requests

app = Flask(__name__)


@app.errorhandler(500)
def _handle_exception(error):
    return error, 500


@app.route('/' + os.environ['SECRET'], methods=['POST'])
def solution_check():
    # If enable_flag_input == True in config.yml:
    #     This URL is replaced with the submitted one
    # Please use relative URL here:
    URL = '/guestbook.php'

    try:
        path = '/' + urlparse(request.json['solution']).path.lstrip('/')
        if not path == '/':
            URL = path + '?' + urlparse(request.json['solution']).query.rstrip('?')
        TEST_ARGS = ['/opt/phantomjs25', '/opt/check.js', URL]
        output = subprocess.check_output(TEST_ARGS, stderr=subprocess.STDOUT, universal_newlines=True, timeout=3)
    except OSError as e:
        return jsonify(solved=False, message='File is not accessible: %s' % ' '.join(TEST_ARGS))

    except subprocess.CalledProcessError:<commit_msg>Solution checking fixed in XSS template<commit_after>import os
import subprocess
from flask import Flask, abort, make_response, jsonify, request
from urllib.parse import urlparse
import requests

app = Flask(__name__)


@app.errorhandler(500)
def _handle_exception(error):
    return error, 500


@app.route('/' + os.environ['SECRET'], methods=['POST'])
def solution_check():
    # If enable_flag_input == True in config.yml:
    #     This URL is replaced with the submitted one
    # Please use relative URL here:
    URL = '/guestbook.php'

    try:
        path = '/' + urlparse(request.json['solution']).path.lstrip('/')
        if not path == '/null':
            URL = path + '?' + urlparse(request.json['solution']).query.rstrip('?')
        TEST_ARGS = ['/opt/phantomjs25', '/opt/check.js', URL]
        output = subprocess.check_output(TEST_ARGS, stderr=subprocess.STDOUT, universal_newlines=True, timeout=3)
    except OSError as e:
        return jsonify(solved=False, message='File is not accessible: %s' % ' '.join(TEST_ARGS))

    except subprocess.CalledProcessError:
{'fraction_non_alphanumeric': 0.13389513108614232, 'fraction_numerical': 0.008426966292134831, 'mean_word_length': 3.72787610619469, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '808042', 'n_tokens_mistral': 687, 'n_tokens_neox': 655, 'n_words': 171}