Full url in QR code won't open when Barcode Scanner is accessed with callback from web page

1,182 views
Skip to first unread message

Peter Gray

unread,
Sep 30, 2013, 11:48:52 AM9/30/13
to zx...@googlegroups.com
Hi.
    I'm trying to use the zxing Barcode Scanner app when called from the browser on Android, using a link to http://zxing.appspot.com/scan. The QR codes contain a full url, in the format https://mysite.com?a=1&b=2. This works just fine, although I have to tap on "Open Browser" to reach the link. When I try to remove this step by adding a ret value to calling link (http://zxing.appspot.com/scan?ret=%7BCODE%7D), the callback will not trigger; Barcode Scanner recognizes the QR code but 
leaves the camera active with a message saying "URL found: https://mysite.com?a=1&b=2". The same also happens if I try with urls in QR codes pointing to other sites. Is there a way around this?
    I can understand the security issues with opening a full url automatically; however, the IOS zxing app from Romain Pechayre does work as I need it to. I've experimented with zxing://scan links (as for the IOS scanner), using {RAWCODE} rather than {CODE}, and trying to use a custom search url of "%s". I'm testing with version 4.4.1 of Barcode Scanner, on Gingerbread 2.3.6.
    regards, P.

Sean Owen

unread,
Sep 30, 2013, 11:55:02 AM9/30/13
to zx...@googlegroups.com
In the URL you show, you have not actually put in a return URL! that's why.

Peter Gray

unread,
Sep 30, 2013, 2:12:43 PM9/30/13
to zx...@googlegroups.com
Hi Sean, I know - it's done that way because the QR codes each contain a full URL, rather than just the parameters.

Sean Owen

unread,
Sep 30, 2013, 7:01:49 PM9/30/13
to zx...@googlegroups.com
Oh you just mean you want it to open automatically? No it won't do that.

Peter Gray

unread,
Oct 1, 2013, 9:07:23 AM10/1/13
to zx...@googlegroups.com
   Can you confirm that it's by design rather than error? I can work around it by submitting the full URL as a parameter, then double-decoding it server-side, but it's a little inelegant. Thanks for the speedy responses - and for zxing in general; it's been excellent for rapid prototyping for me.

Sean Owen

unread,
Oct 1, 2013, 1:14:23 PM10/1/13
to zx...@googlegroups.com
It's by design, yes. I don't think anything on your server side would change that though, so I'm not sure i'm understanding.

Peter Gray

unread,
Oct 2, 2013, 10:05:33 AM10/2/13
to zx...@googlegroups.com
OK, my workaround functions as needed. If anyone else has the same problem, I addressed it in php as follows:
1. Replaced the link to trigger zxing Barcode Scanner with:
2. Added the following to the top of targetpage.php:
if (isset($_GET['url'])) {
  $url_data
= parse_url($_GET['url']);
  parse_str
($url_data['query'], $params);
  $_GET
= array_merge($_GET, $params);
}
Please note that the above does not provide any data validation. However, this approach does allow the QR codes to work with other QR readers, if a little less elegantly than with zxing.


On Monday, September 30, 2013 5:48:52 PM UTC+2, Peter Gray wrote:
Reply all
Reply to author
Forward
0 new messages