1*60ea9a07SPhy<?php 2*60ea9a07SPhy 3*60ea9a07SPhyclass common_getGoogleQuery_test extends DokuWikiTest { 4*60ea9a07SPhy 5*60ea9a07SPhy /** 6*60ea9a07SPhy * https://github.com/splitbrain/dokuwiki/issues/2848 7*60ea9a07SPhy */ 8*60ea9a07SPhy function test_google_form(){ 9*60ea9a07SPhy global $INPUT; 10*60ea9a07SPhy $_SERVER['HTTP_REFERER'] = 'https://www.google.com/url?q=https://www.dokuwiki.org/&sa=D&ust=a&usg=b'; 11*60ea9a07SPhy $INPUT = new Input(); 12*60ea9a07SPhy $this->assertEquals('', getGoogleQuery()); 13*60ea9a07SPhy } 14*60ea9a07SPhy 15*60ea9a07SPhy function test_google_url(){ 16*60ea9a07SPhy global $INPUT; 17*60ea9a07SPhy $_SERVER['HTTP_REFERER'] = 'https://www.google.com/url?sa=t&source=web&rct=j&url=https://www.dokuwiki.org/&ved=a'; 18*60ea9a07SPhy $INPUT = new Input(); 19*60ea9a07SPhy $this->assertEquals('', getGoogleQuery()); 20*60ea9a07SPhy } 21*60ea9a07SPhy 22*60ea9a07SPhy function test_uncommon_url(){ 23*60ea9a07SPhy global $INPUT; 24*60ea9a07SPhy $_SERVER['HTTP_REFERER'] = 'http://search.example.com/search?q=DokuWiki'; 25*60ea9a07SPhy $INPUT = new Input(); 26*60ea9a07SPhy $this->assertEquals('', getGoogleQuery()); 27*60ea9a07SPhy } 28*60ea9a07SPhy 29*60ea9a07SPhy function test_old_google(){ 30*60ea9a07SPhy global $INPUT; 31*60ea9a07SPhy $_SERVER['HTTP_REFERER'] = 'https://www.google.com/search?newwindow=1&q=what%27s+my+referer'; 32*60ea9a07SPhy $INPUT = new Input(); 33*60ea9a07SPhy $this->assertEquals(array('what', 's', 'my', 'referer'), getGoogleQuery()); 34*60ea9a07SPhy } 35*60ea9a07SPhy 36*60ea9a07SPhy} 37*60ea9a07SPhy 38*60ea9a07SPhy//Setup VIM: ex: et ts=4 : 39