1/** 2 * Created by Mike on 19.04.14. 3 */ 4// using jQuery 5function getCookie(name) { 6 var cookieValue = null; 7 if (document.cookie && document.cookie != '') { 8 var cookies = document.cookie.split(';'); 9 for (var i = 0; i < cookies.length; i++) { 10 var cookie = jQuery.trim(cookies[i]); 11 // Does this cookie string begin with the name we want? 12 if (cookie.substring(0, name.length + 1) == (name + '=')) { 13 cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); 14 break; 15 } 16 } 17 } 18 return cookieValue; 19} 20 21var csrftoken = getCookie('csrftoken'); 22 23function csrfSafeMethod(method) { 24 // these HTTP methods do not require CSRF protection 25 return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); 26} 27function sameOrigin(url) { 28 // test that a given url is a same-origin URL 29 // url could be relative or scheme relative or absolute 30 var host = document.location.host; // host + port 31 var protocol = document.location.protocol; 32 var sr_origin = '//' + host; 33 var origin = protocol + sr_origin; 34 // Allow absolute or scheme relative URLs to same origin 35 return (url == origin || url.slice(0, origin.length + 1) == origin + '/') || 36 (url == sr_origin || url.slice(0, sr_origin.length + 1) == sr_origin + '/') || 37 // or any other URL that isn't scheme relative or absolute i.e relative. 38 !(/^(\/\/|http:|https:).*/.test(url)); 39} 40$.ajaxSetup({ 41 beforeSend: function(xhr, settings) { 42 if (!csrfSafeMethod(settings.type) && sameOrigin(settings.url)) { 43 // Send the token to same-origin, relative URLs only. 44 // Send the token only if the method warrants CSRF protection 45 // Using the CSRFToken value acquired earlier 46 xhr.setRequestHeader("X-CSRFToken", csrftoken); 47 } 48 } 49});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.