New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan via browser URL seems to cache redirect and return to wrong location #302

Closed
tjwood100 opened this Issue Jan 30, 2015 · 11 comments

Comments

Projects
None yet
5 participants
@tjwood100

tjwood100 commented Jan 30, 2015

I have developed a simple web app we use for tracking boxes at work which updates a database.

The boxes all have barcodes attached.

This is somewhat simplified, but for the purposes of this bug report I have two pages in the web app:

  • Look up a box
  • Add a new box

On the "add a new box" page I have a button which links to Barcode Scanner with a URL like:
http://zxing.appspot.com/scan?ret=https%3A%2F%2Fmyserver.example.com%2Faddbox.php%3F%26xid%3D%7BCODE%7D

On the "look up a box" page I have a similar button but it links to a different URL:
http://zxing.appspot.com/scan?ret=https%3A%2F%2Fmyserver.example.com%2Flookupbox.php%3F%26xid%3D%7BCODE%7D

However, I find if I go to "add a new box", scan a barcode with a particular value (doesn't seem to matter what type of barcode, I've reproduced with code 128 and with QR code), I am redirected correctly. But if I later go to "look up a box" and scan the same barcode, it returns me to addbox.php not lookupbox.php even though the link on the "look up a box" page was definitely correct.

If I scan a different barcode on the "look up a box" page I'm correctly redirected to lookupbox.php. If I clear all zxing's app data, and go to the "look up a box" page, and scan the same barcode, I'm also correctly redirected to lookupbox.php.

It looks like zxing is somehow caching the ret= value along with a particular barcode and refusing to change it on a later scan of the same code.

This breaks my web app's functionality. I guess the only way I can really work around it is by redirecting all scans to the same scan.php page and then using PHP session variables or something to tell scan.php where I really want to be redirected to. This is, quite obviously, a pain.

I'm using Barcode Scanner version 4.7.0 on a Sony Xperia Z2 running Android 4.4.4.

@srowen

This comment has been minimized.

Contributor

srowen commented Jan 30, 2015

Hm, I might see the problem. Can I send you a debug build to test, or are you in a position to build from a branch here?

@tjwood100

This comment has been minimized.

tjwood100 commented Jan 30, 2015

If you can tell me how to install the debug build, I'm happy to test it. I don't have a rooted phone.

I put together a trivial test example - and in creating it found the bug is slightly different to what I thought.

http://www.tx9.co.uk/zxingtest.php

I cleared app data, then used the "go to a.php" link and scan a barcode, it takes me to a.php
Then I use the "go to b.php" link and scan the same code, and go to b.php
Then I go back and use the "go to a.php" link and always end up at b.php, even if I scan a different code.

@srowen

This comment has been minimized.

Contributor

srowen commented Jan 30, 2015

Can you try this build? if you uninstall the app and then click the link, and have chosen in Settings to allow untrusted non-Play apps, it should just install.
https://drive.google.com/file/d/0B_hfrkaWlLi4cVd2WWEtb21FTzA/view?usp=sharing

@tjwood100

This comment has been minimized.

tjwood100 commented Jan 30, 2015

Yes, that build does seem to fix the issue.

@srowen srowen closed this Jan 31, 2015

@srowen srowen added this to the 3.2.0 milestone Jan 31, 2015

@srowen srowen self-assigned this Jan 31, 2015

@Tzvetelin88

This comment has been minimized.

Tzvetelin88 commented May 31, 2015

Hello, I also have a problem with redirection for my custom web application.

I downloaded : https://drive.google.com/file/d/0B_hfrkaWlLi4cVd2WWEtb21FTzA/view?usp=sharing and make a test with: http://www.tx9.co.uk/zxingtest.php on my:
Nexus 6 android 5.0.1 and
Asus MemoPad HD7 4.4.2

When a go to a.php and scan - redirect to a.php
after that I go to b.php and scan - redirect to b.php
after that I go to a.php and scan - redirect to b.php - Not correct.

Can you help me fix that ?

Regards,
TB

@kckam

This comment has been minimized.

kckam commented Jun 10, 2015

I've found a manual solution for this issue.

When a go to a.php and scan - redirect to a.php
after that I go to b.php and scan - redirect to b.php
after that I go to a.php and scan - [Solution]Press back button until the barcode scanner apps closes. Then scan again and will solve the redirection problem.

I don't think this is a optimum solution, hope i am giving a new direction for you to find the bug.

Regards,
KC

@orolyn

This comment has been minimized.

orolyn commented Jun 10, 2015

I've just had to deal with this issue myself. I was about to reimplement my app to use a single URL and a session, but before that I tried generating the urls as:

<?php
$url = sprintf('zxing://scan/?ret=my-site.com?code={CODE}&buster=%s', time());

This appears to have solved the problem, with a tad more elegance at least..

@srowen

This comment has been minimized.

Contributor

srowen commented Jun 10, 2015

@Tzvetelin88 I tried your test again and the app works correctly, and doesn't do what you describe. I'm just using 4.7.3 from Play which has the fix.

I'm not sure what's different, since the app clears these values every time it is resumed, and it must be resumed if it's coming from the background.

@orolyn I don't think that can be relevant as the old problem was that the previous URL was remembered. Passing different URLs the next time didn't matter then.

@orolyn

This comment has been minimized.

orolyn commented Jun 10, 2015

@srowen I am also using 4.7.3

My app uses two triggers of this URL, each often scanning the same qr code.
My use case is exactly the same as @kckam describes.

First and second work fine, but going back to first again, and it repeats the second. Unless I used this modified URL. Or this app was updated on play within the last couple of hours.

@Tzvetelin88

This comment has been minimized.

Tzvetelin88 commented Jun 11, 2015

Hello,
@orolyn , thank you very much! I used you modified link:

@srowen

This comment has been minimized.

Contributor

srowen commented Jun 11, 2015

If that works then I think this must be a case of browser caching? The fact that a different URL makes a difference later means the app is passing it through correctly.

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