#213 relative urls with multiple dots in them fail click()

open
Marcus Baker
Web tester (52)
5
2012-01-14
2012-01-14
Peter Meth
No

SimpleTest
version: 1.1.alpha3

Every time I tried to perform $this->click($label) or $this->clickLink($label) on a relative url with multiple dots in it, I would get an exception thrown and my tests would not run.

Steps to reproduce:
file1.html:
<a href='file.2.html'>file2</a>

file.2.html:
<div>hi</div>

TestBug.php:
<?php

require_once('simpletest/autorun.php');
require_once('simpletest/web_tester.php');

class TestBug extends WebTestCase {
function testBug() {
$this->get('http://localhost/file1.html');
$this->clickLink('file2');
$this->assertText('hi');
}
}

-----------------
I believe I found where the problem is and am proposing a patch. Please note, I am guessing at the intent of the following regex as there are no inline comments.

simpletest/url.php line 153:
--- } elseif (preg_match('/[a-z0-9\-]+\.[a-z0-9\-]+\.[a-z0-9\-]+/i', $matches[1])) {
+++ } elseif (preg_match('/[a-z0-9\-]+\.[a-z0-9\-]+\.(' . $tlds . ')/i', $matches[1])) {

Discussion