$method, 'REQUEST_URI' => $uri); if ($ua !== null) { $server['HTTP_USER_AGENT'] = $ua; } if (txiaw_should_block_home_request($server, $query) !== $expected) { fwrite(STDERR, 'Failed request guard: ' . $method . ' ' . $uri . "\n"); exit(1); } } check_guard('GET', '/?r=123', null, array('r' => '123'), true); check_guard('HEAD', '/?r=123', '', array('r' => '123'), true); check_guard('GET', '/index.php?x=1&r=123', ' ', array('x' => '1', 'r' => '123'), true); check_guard('GET', '/?r=', '', array('r' => ''), true); check_guard('GET', '/?r[]=123', '', array('r' => array('123')), true); check_guard('GET', '/?r=123', 'Mozilla/5.0', array('r' => '123'), false); check_guard('GET', '/', null, array(), false); check_guard('GET', '/?utm_source=test', null, array('utm_source' => 'test'), false); check_guard('GET', '/down/184778.html?r=1', null, array('r' => '1'), false); check_guard('POST', '/index.php?r=1', null, array('r' => '1'), false); check_guard('GET', '/.well-known/acme-challenge/test?r=1', null, array('r' => '1'), false); echo "PASS: 11 guard cases; normal homepage, browser, article, POST and ACME requests preserved.\n";