WebAssert::addressEquals($page) doesn't work on urls containing utf-8 characters
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.6k
- Forks
- 286
- PR merge metrics
- No merged PRs in 30d
Description
Scenario Outline: Verify redirects are working correctly
When I visit "/de/help/help-topics/puffle-launch/how-do-i-pause-game"
Then I should be on "/articles/de/FAQ/Tipps-und-Tricks-für-Puffle-Flug"
Exception:
Current page is "/articles/de/FAQ/Tipps-und-Tricks-f%C3%BCr-Puffle-Flug", but "/articles/de/FAQ/Tipps-und-Tricks-für-Puffle-Flug" expected.
The browser returns an encoded url but is compared with a straight string compare with the un-encoded expected url. As an added issue the Russian language urls were even more impacted due to the php parse_url removing several of the russian characters from the url.
The following code change fixes both issues.
/**
* Checks that current session address is equals to provided one.
*
* @param string $page
*
* @throws ExpectationException
*/
public function addressEquals($page)
{
// $expected = $this->cleanScriptnameFromPath(parse_url($page, PHP_URL_PATH));
// $actual = $this->getCurrentUrlPath();
//Deal correctly with UTF-8 urls
$encodedPage = preg_replace('%[^:/?#&=\.]+%usDe', 'urlencode(\'$0\')', $page);
$expected = urldecode($this->cleanScriptnameFromPath(parse_url($encodedPage, PHP_URL_PATH)));
$actual = urldecode($this->getCurrentUrlPath());
if (strcmp($actual,$expected)) {
$message = sprintf('Current page is "%s", but "%s" expected.', $actual, $expected);
throw new ExpectationException($message, $this->session);
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at WebAssert::addressEquals($page), the entry point named in the issue, and inspect how parse_url, getCurrentUrlPath, and URL encoding are currently used. Reproduce the UTF-8 example and verify that address comparisons handle encoded German and Russian URL characters without changing the expected path semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100