Skip to content

fix handling of Location headers with commas#12

Open
skaurus wants to merge 1 commit intotadam:masterfrom
skaurus:patch-2
Open

fix handling of Location headers with commas#12
skaurus wants to merge 1 commit intotadam:masterfrom
skaurus:patch-2

Conversation

@skaurus
Copy link

@skaurus skaurus commented Oct 16, 2015

Also, your header splitting by comma is broken anyway.
Line my @v = $s =~ /^([^ ].*?[^ ],)*([^ ].*?[^ ])$/; copied from your module.

$ perl -MData::Dumper -e 'my $s = q[aa,bb,cc,dd,ee]; my @v = $s =~ /^([^ ].*?[^ ],)*([^ ].*?[^ ])$/; print Dumper(\@v);'
$VAR1 = [
          'dd,',
          'ee'
        ];

@skaurus
Copy link
Author

skaurus commented Oct 16, 2015

Moreover, you have at least one more bug.

I have an url, https://ad.doubleclick.net/ddm/clk/296499516;123539294;y
It may not work at time you (hopefully) take a look at it. But what important is that it have Location header https://d.agkn.com/pixel/2389/?che=1577461220&col=9097567,1688645,123539294,296499516,0&l0=http://www.peugeot.ru/promo-details/408-promo-offer/?utm_source=Surfingbird_TGB_408day_15CD&utm_medium=D_CPM&utm_campaign=2015_10_PEUGEOT_15CD_Campaign_DIP_AP_RU_TF

That url in turn have Location header http://www.peugeot.ru/promo-details/408-promo-offer/?utm_source=Surfingbird_TGB_408day_15CD&utm_medium=D_CPM&utm_campaign=2015_10_PEUGEOT_15CD_Campaign_DIP_AP_RU_TF.

What does happened before this patch is that your module tried to donwload url https://ad.doubleclick.net/296499516,%200&l0=http://www.peugeot.ru/promo-details/408-promo-offer/?utm_source=Surfingbird_TGB_408day_15CD&utm_medium=D_CPM&utm_campaign=2015_10_PEUGEOT_15CD_Campaign_DIP_AP_RU_TF, note the domain. I guess your ->base() method is broken for combination of "redirection url" + "converting relative urls to absolute ones".

Single-liner:

$ ./script/perl -e 'use AnyEvent::HTTP::LWP::UserAgent; my $ua = AnyEvent::HTTP::LWP::UserAgent->new(agent => "Relap fetcher", timeout => 10); my $pageurl = "https://ad.doubleclick.net/ddm/clk/296499516;123539294;y"; my $cv = AnyEvent->condvar(); $cv->begin(sub { shift()->send() }); $cv->begin(); $ua->get_async($pageurl)->cb(sub { chain_url_fetched(shift()->recv(), $ua, $cv);}); $cv->end(); $cv->recv(); sub chain_url_fetched { my ($response, $ua, $cv) = @_; my $redirects = []; my $prev_response = $response; while ($prev_response->previous()) { unshift(@$redirects, $prev_response->base().""); $prev_response = $prev_response->previous(); } warn sprintf("%s; url: %s\n", $response->status_line(), $response->base()); $cv->end() }'
404 Not Found; url: https://ad.doubleclick.net/296499516,%200&l0=http://www.peugeot.ru/promo-details/408-promo-offer/?utm_source=Surfingbird_TGB_408day_15CD&utm_medium=D_CPM&utm_campaign=2015_10_PEUGEOT_15CD_Campaign_DIP_AP_RU_TF

@tadam
Copy link
Owner

tadam commented Jan 18, 2016

@skaurus Sorry that I ignored your pull requests. I'm not going to maintain any of my Perl modules. Would you like to be the maintainer of this one?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants