<commit_before><?php require dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'src', '_autoload.php']);

function makeQueryString($args) {
	$args = array_merge($_GET, $args);
	reset($args);
	foreach($args as $key => $value) {
		if (is_null($value)) {
			unset($args[$key]);
		}
	}
	return '?' . http_build_query($args);
}

$cat = new \Eduroam\CAT\CAT();
$idp = new \Eduroam\Connect\IdentityProvider($cat, $_GET['idp']);
$profile = new \Eduroam\Connect\Profile($cat, $_GET['idp'], $_GET['profile']);
$profiles = \Eduroam\Connect\Profile::getProfilesByIdPEntityID($cat, $_GET['idp']);

$canListProfiles = count($profiles) > 1;

$devices = $profile->getDevices();
$os = null;
if (isset($_GET['os'])) {
	$os = $_GET['os'];
} else {
	if (array_key_exists('HTTP_SEC_CH_PLATFORM', $_SERVER)) {
		$os = \Eduroam\Connect\Device::guessDeviceID($_SERVER['HTTP_SEC_CH_PLATFORM'], array_keys($devices));
	} else {
		header('Accept-CH: Platform');
		$os = \Eduroam\Connect\Device::guessDeviceID($_SERVER['HTTP_USER_AGENT'], array_keys($devices));
	}
}

$device = null !== $os && array_key_exists($os, $devices)
	? $profile->getDevices()[$os]
	: null;
	;

if (null === $device) {
	$file = __DIR__ . DIRECTORY_SEPARATOR . 'list.php';
} else {
	$file = __DIR__ . DIRECTORY_SEPARATOR . 'download.php';
}
include $file;
<commit_msg>Prevent guessing device when User Agent is hidden<commit_after><?php require dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'src', '_autoload.php']);

function makeQueryString($args) {
	$args = array_merge($_GET, $args);
	reset($args);
	foreach($args as $key => $value) {
		if (is_null($value)) {
			unset($args[$key]);
		}
	}
	return '?' . http_build_query($args);
}

$cat = new \Eduroam\CAT\CAT();
$idp = new \Eduroam\Connect\IdentityProvider($cat, $_GET['idp']);
$profile = new \Eduroam\Connect\Profile($cat, $_GET['idp'], $_GET['profile']);
$profiles = \Eduroam\Connect\Profile::getProfilesByIdPEntityID($cat, $_GET['idp']);

$canListProfiles = count($profiles) > 1;

$devices = $profile->getDevices();
$os = null;
if (isset($_GET['os'])) {
	$os = $_GET['os'];
} else {
	if (array_key_exists('HTTP_SEC_CH_PLATFORM', $_SERVER)) {
		$os = \Eduroam\Connect\Device::guessDeviceID($_SERVER['HTTP_SEC_CH_PLATFORM'], array_keys($devices));
	} else {
		header('Accept-CH: Platform');
		if (array_key_exists('HTTP_USER_AGENT', $_SERVER)) {
			$os = \Eduroam\Connect\Device::guessDeviceID($_SERVER['HTTP_USER_AGENT'], array_keys($devices));
		}
	}
}

$device = null !== $os && array_key_exists($os, $devices)
	? $profile->getDevices()[$os]
	: null;
	;

if (null === $device) {
	$file = __DIR__ . DIRECTORY_SEPARATOR . 'list.php';
} else {
	$file = __DIR__ . DIRECTORY_SEPARATOR . 'download.php';
}
include $file;

{'fraction_non_alphanumeric': 0.2096069868995633, 'fraction_numerical': 0.000727802037845706, 'mean_word_length': 5.838308457711443, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6778358', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1050, 'n_words': 172}