Index: trunk/extensions/MobileFrontend/MobileFrontend.body.php |
— | — | @@ -710,15 +710,23 @@ |
711 | 711 | return $url; |
712 | 712 | } |
713 | 713 | |
| 714 | + /** |
| 715 | + * Disables caching if the request is coming from a trusted proxy |
| 716 | + */ |
714 | 717 | private function disableCaching() { |
715 | 718 | global $wgRequest; |
716 | 719 | wfProfileIn( __METHOD__ ); |
717 | | - if ( isset( $_SERVER['HTTP_VIA'] ) && |
718 | | - stripos( $_SERVER['HTTP_VIA'], '.wikimedia.org:3128' ) !== false ) { |
| 720 | + |
| 721 | + // Fetch the REMOTE_ADDR and check if it's a trusted proxy. |
| 722 | + // Is this enough, or should we actually step through the entire |
| 723 | + // X-FORWARDED-FOR chain? |
| 724 | + $ip = $wgRequest->getRawIP(); |
| 725 | + if ( wfIsTrustedProxy ( $ip )) { |
719 | 726 | $wgRequest->response()->header( 'Cache-Control: no-cache, must-revalidate' ); |
720 | 727 | $wgRequest->response()->header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); |
721 | 728 | $wgRequest->response()->header( 'Pragma: no-cache' ); |
722 | 729 | } |
| 730 | + |
723 | 731 | wfProfileOut( __METHOD__ ); |
724 | 732 | return true; |
725 | 733 | } |