{"id":2827,"date":"2021-03-06T13:00:00","date_gmt":"2021-03-06T13:00:00","guid":{"rendered":"https:\/\/chewett.co.uk\/blog\/?p=2827"},"modified":"2021-03-08T22:17:59","modified_gmt":"2021-03-08T22:17:59","slug":"the-risks-of-windows-and-linux-line-endings-in-git-with-pogoapi","status":"publish","type":"post","link":"https:\/\/chewett.co.uk\/blog\/2827\/the-risks-of-windows-and-linux-line-endings-in-git-with-pogoapi\/","title":{"rendered":"The Risks of Windows and Linux Line endings in Git with PoGoAPI"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"678\" height=\"254\" data-attachment-id=\"2836\" data-permalink=\"https:\/\/chewett.co.uk\/blog\/2827\/the-risks-of-windows-and-linux-line-endings-in-git-with-pogoapi\/pogoapi_git_lines_header\/\" data-orig-file=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/03\/pogoapi_git_lines_header.jpg?fit=800%2C300&amp;ssl=1\" data-orig-size=\"800,300\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"pogoapi_git_lines_header\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/03\/pogoapi_git_lines_header.jpg?fit=300%2C113&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/03\/pogoapi_git_lines_header.jpg?fit=678%2C254&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/03\/pogoapi_git_lines_header.jpg?resize=678%2C254&#038;ssl=1\" alt=\"\" class=\"wp-image-2836\" srcset=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/03\/pogoapi_git_lines_header.jpg?w=800&amp;ssl=1 800w, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/03\/pogoapi_git_lines_header.jpg?resize=300%2C113&amp;ssl=1 300w, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/03\/pogoapi_git_lines_header.jpg?resize=768%2C288&amp;ssl=1 768w, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/03\/pogoapi_git_lines_header.jpg?resize=50%2C19&amp;ssl=1 50w\" sizes=\"auto, (max-width: 678px) 100vw, 678px\" \/><\/figure>\n\n\n\n<p>This talks about the minor changes needed for the api_hashes api to allow verifying API&#8217;s.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Original Problem<\/h2>\n\n\n\n<p>Someone contacted me and said they couldnt verify the API&#8217;s against the hashes I provided. I looked into this and locally there didnt seem to be an issue as the API&#8217;s matched directly.<\/p>\n\n\n\n<p>However when I looked at the server the files didn&#8217;t match the verified hashes stored. I initially thought this to be odd as I checked the files into git and therefore they couldn&#8217;t change. The files locally should have been the same as the files on the server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Git being &#8220;helpful&#8221;<\/h2>\n\n\n\n<p>One of the features of git is the line ending checkout mode. By default if you check out a git repository on your machine it will check out the line endings for your system.<\/p>\n\n\n\n<p>What this meant is that on my windows desktop I created files with windows line endings that were then checked into git as linux line endings. This meant that the files stored in git had a different hash to the ones that were checked out locally on my Windows machine.<\/p>\n\n\n\n<p>The Linux server I run PoGoAPI on therefore had Linux line endings as it was checked out from git.<\/p>\n\n\n\n<p>Since I was generating the hash file locally too, these hashes were for files with windows line endings. This meant that the only way to verify the API&#8217;s was to convert the line endings to windows endings and then verify it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Changing it to create the hashes on the server<\/h2>\n\n\n\n<p>Instead of checking in the hash file I have changed the update script so that it also generates the hash file on update. This means that the files served to those using the API always have the same hash as in the hash file.<\/p>\n\n\n\n<p>After making these changes the api hash file should always be correct.<\/p>\n\n\n\n<p>Its an interesting learning experience as a useful feature of git caused a small unintended bug.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This talks about the minor changes needed for the api_hashes api to allow verifying API&#8217;s.<\/p>\n","protected":false},"author":1,"featured_media":2835,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5],"tags":[228,224,218],"class_list":["post-2827","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-informational","tag-git","tag-pogoapi","tag-pokemon-go"],"wppr_data":{"cwp_meta_box_check":"No"},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/03\/pogoapi_git_issues_posticon_OUTPUT.png?fit=1200%2C628&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p2toWX-JB","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":2162,"url":"https:\/\/chewett.co.uk\/blog\/2162\/pokemon-go-api-api-hashes-api\/","url_meta":{"origin":2827,"position":0},"title":"Pokemon Go API \u2013 API Hashes API","author":"Chewett","date":"May 1, 2019","format":false,"excerpt":"This post talks about the newest Pokemon Go API, the API Hashes API at pogoapi.net. Using the API Hashes API It is recommended to locally cache the API files so you can store them on your own server and use them as needed. To help facilitate this hash API is\u2026","rel":"","context":"In &quot;Software&quot;","block_context":{"text":"Software","link":"https:\/\/chewett.co.uk\/blog\/category\/software\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/04\/pogo_api_hashes.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/04\/pogo_api_hashes.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/04\/pogo_api_hashes.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/04\/pogo_api_hashes.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":989,"url":"https:\/\/chewett.co.uk\/blog\/989\/introducing-pokemon-go-data-api-pogoapi-net\/","url_meta":{"origin":2827,"position":1},"title":"Introducing the Pokemon Go Data API &#8211; pogoapi.net","author":"Chewett","date":"February 3, 2018","format":false,"excerpt":"This post introduces the Pokemon Go API website, PoGoAPI.net and what I plan to do with it. Whats the website? PoGoAPI.net! I started to play around with some data visualization and tools to help play Pokemon Go. However I couldn't find the information I wanted easily. Lists of information is\u2026","rel":"","context":"In &quot;Software&quot;","block_context":{"text":"Software","link":"https:\/\/chewett.co.uk\/blog\/category\/software\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/pogo_api_released.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/pogo_api_released.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/pogo_api_released.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/pogo_api_released.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":1020,"url":"https:\/\/chewett.co.uk\/blog\/1020\/pokemon-go-api-list-pokemon-names\/","url_meta":{"origin":2827,"position":2},"title":"Pokemon Go API &#8211; List of Pokemon Names","author":"Chewett","date":"February 17, 2018","format":false,"excerpt":"Here I talk about the first public API for the PoGoAPI.net website and what it does. First Public API and Documentation Today I have launched the first public API for PoGoAPI.net and the associated (short) documentation for it. Earlier I talked about launching the domain and some of the plans\u2026","rel":"","context":"In &quot;Software&quot;","block_context":{"text":"Software","link":"https:\/\/chewett.co.uk\/blog\/category\/software\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/pogo_api_pokemon_names.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/pogo_api_pokemon_names.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/pogo_api_pokemon_names.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/pogo_api_pokemon_names.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":2961,"url":"https:\/\/chewett.co.uk\/blog\/2961\/enabling-cross-origin-resource-sharing-cors-on-pogoapi-net\/","url_meta":{"origin":2827,"position":3},"title":"Enabling Cross-Origin Resource Sharing (CORS) on PoGoAPI.net","author":"Chewett","date":"July 31, 2021","format":false,"excerpt":"This blog post talks about enabling Cross-Origin Resource Sharing (CORS) on PoGoAPI.net What is CORS (Cross-Origin Resource Sharing) Cross-Origin Resource Sharing defines whether a browser can load resources from other origins different from the one that it is currently loading. By default browsers will only load resources from the same\u2026","rel":"","context":"In &quot;Software&quot;","block_context":{"text":"Software","link":"https:\/\/chewett.co.uk\/blog\/category\/software\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/07\/pogoapi_cors_posticon.png?fit=1200%2C628&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/07\/pogoapi_cors_posticon.png?fit=1200%2C628&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/07\/pogoapi_cors_posticon.png?fit=1200%2C628&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/07\/pogoapi_cors_posticon.png?fit=1200%2C628&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/07\/pogoapi_cors_posticon.png?fit=1200%2C628&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":1777,"url":"https:\/\/chewett.co.uk\/blog\/1777\/pokemon-go-api-pokemon-types-api\/","url_meta":{"origin":2827,"position":4},"title":"Pokemon Go API &#8211; Pokemon Types API","author":"Chewett","date":"January 23, 2019","format":false,"excerpt":"This post talks about the newest Pokemon Go API, the Pokemon Types API at\u00a0pogoapi.net. Pokemon Type Data All Pokemon have either one or two types, these types affect the strength of moves and weaknesses it has to opponents moves. Getting the Pokemon Types Data This API lists the types of\u2026","rel":"","context":"In &quot;Software&quot;","block_context":{"text":"Software","link":"https:\/\/chewett.co.uk\/blog\/category\/software\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/11\/pogo_api_pokemon_types-1.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/11\/pogo_api_pokemon_types-1.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/11\/pogo_api_pokemon_types-1.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/11\/pogo_api_pokemon_types-1.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":2623,"url":"https:\/\/chewett.co.uk\/blog\/2623\/pokemon-go-api-research-task-exclusive-pokemon-api\/","url_meta":{"origin":2827,"position":5},"title":"Pokemon Go API &#8211; Research Task Exclusive Pokemon API","author":"Chewett","date":"September 19, 2020","format":false,"excerpt":"This post talks about the latest API I have added to PoGoAPI.net, the Research Task Exclusive Pokemon API. What is the Research Task Exclusive Pokemon API Some Pokemon and their evolutions are only available by completing research tasks. To get these you will have to find the research task by\u2026","rel":"","context":"In &quot;Software&quot;","block_context":{"text":"Software","link":"https:\/\/chewett.co.uk\/blog\/category\/software\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2020\/08\/pogo_api_raid_research_exclusive_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2020\/08\/pogo_api_raid_research_exclusive_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2020\/08\/pogo_api_raid_research_exclusive_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2020\/08\/pogo_api_raid_research_exclusive_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2020\/08\/pogo_api_raid_research_exclusive_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/2827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=2827"}],"version-history":[{"count":6,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/2827\/revisions"}],"predecessor-version":[{"id":2837,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/2827\/revisions\/2837"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/media\/2835"}],"wp:attachment":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=2827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=2827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=2827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}