Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Encode not allowed characters in URL. #422

wants to merge 1 commit into


None yet
4 participants

Locke23rus commented Nov 21, 2012

No description provided.

@mhoran - when do you think this will get pulled in?

Hi @HeiaHeia,

I'm eager to this this error fixed so I forked the original capybara-webkit and applied your change to master. Unfortunately it's not working so I wanted to share my output.

My brew version

brew info qt
qt: stable 4.8.5 (bottled), HEAD
/usr/local/Cellar/qt/4.8.5 (2777 files, 119M) *
  Poured from bottle
From: https://github.com/mxcl/homebrew/commits/master/Library/Formula/qt.rb
==> Dependencies
Optional: d-bus, mysql
==> Options
    Build and link with developer options
    Build a universal binary
    Build with d-bus support
    Build documentation
    Build with mysql support
    Build with deprecated Qt3Support module support
==> Caveats
We agreed to the Qt opensource license for you.
If this is unacceptable you should uninstall.

Rspec output

rspec spec/driver_spec.rb -l 427
Run options:
  include {:line_numbers=>[427]}
  exclude {:requires=>#<Proc:0x007fe13cb44bd0>, :skip_on_windows=>false}

  hello app
    returns the current URL with encoded characters (FAILED - 1)


  1) Capybara::Webkit::Driver hello app returns the current URL with encoded characters
     Failure/Error: driver.visit "/hello/world?success[value]=true"
       Unable to load URL: file:///hello/world?success[value]=true because of error loading file:///hello/world?success[value]=true: Unknown error
     # ./lib/capybara/webkit/browser.rb:215:in `check'
     # ./lib/capybara/webkit/browser.rb:152:in `command'
     # ./lib/capybara/webkit/browser.rb:18:in `visit'
     # ./lib/capybara/webkit/driver.rb:29:in `visit'
     # ./spec/driver_spec.rb:428:in `block (3 levels) in <top (required)>'

Finished in 0.04662 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/driver_spec.rb:427 # Capybara::Webkit::Driver hello app returns the current URL with encoded characters

You can see I applied your changes directly.

diff --git a/spec/driver_spec.rb b/spec/driver_spec.rb
index c705b5e..d82593d 100644
--- a/spec/driver_spec.rb
+++ b/spec/driver_spec.rb
@@ -424,6 +424,11 @@ describe Capybara::Webkit::Driver do
       driver.current_url.should =~ /success=\%25true/

+    it "returns the current URL with encoded characters" do
+      driver.visit "/hello/world?success[value]=true"
+      driver.current_url.should =~ /success\%5Bvalue\%5D=true/
+    end
     it "visits a page with an anchor" do
       driver.current_url.should =~ /hello#display_none/
diff --git a/src/Visit.cpp b/src/Visit.cpp
index 0fecc28..f7256b2 100644
--- a/src/Visit.cpp
+++ b/src/Visit.cpp
@@ -7,7 +7,7 @@ Visit::Visit(WebPageManager *manager, QStringList &arguments, QObject *parent) :

 void Visit::start() {
-  QUrl requestedUrl = QUrl::fromEncoded(arguments()[0].toUtf8(), QUrl::StrictMode);
+  QUrl requestedUrl = QUrl::fromEncoded(arguments()[0].toUtf8(), QUrl::TolerantMode);

jferris commented Nov 9, 2013

Sorry for the delay on this one. I updated, fixed some Qt 5 errors, and squashed as f24a03b on thoughtbot:jf-ignore-invalid-urls. This will be merged as soon as the build passes.

@jferris jferris closed this Nov 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment