Skip to content

Commit

Permalink
Use https everywhere, fixes #43 (#44)
Browse files Browse the repository at this point in the history
* Use https everywhere, fixes #43

* Test PHP 7.1 and remove HHVM testing.
  • Loading branch information
ThePixelDeveloper authored Jul 26, 2017
1 parent 013b332 commit 33733b9
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ language: php
php:
- 5.6
- 7.0
- hhvm
- 7.1

before_script:
- composer install --prefer-dist --classmap-authoritative --no-interaction --no-progress
Expand Down
106 changes: 53 additions & 53 deletions spec/OutputSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ function it_should_format_a_sitemapindex_with_n_sitemaps()
{
$xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemapindex xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>http://www.example.com/sitemap1.xml.gz</loc>
<loc>https://www.example.com/sitemap1.xml.gz</loc>
</sitemap>
<sitemap>
<loc>http://www.example.com/sitemap1.xml.gz</loc>
<loc>https://www.example.com/sitemap1.xml.gz</loc>
</sitemap>
</sitemapindex>
XML;

$sitemapIndex = new SitemapIndex();
$sitemapIndex->addSitemap(new Sitemap('http://www.example.com/sitemap1.xml.gz'));
$sitemapIndex->addSitemap(new Sitemap('http://www.example.com/sitemap1.xml.gz'));
$sitemapIndex->addSitemap(new Sitemap('https://www.example.com/sitemap1.xml.gz'));
$sitemapIndex->addSitemap(new Sitemap('https://www.example.com/sitemap1.xml.gz'));

$this->getOutput($sitemapIndex)->shouldReturn($xml);
}
Expand All @@ -43,51 +43,51 @@ function it_should_generate_a_sitemap_of_images()
{
$xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<urlset xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="https://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>http://www.example.com/1</loc>
<loc>https://www.example.com/1</loc>
<image:image>
<image:loc>https://s3.amazonaws.com/path/to/image</image:loc>
<image:loc>httpss://s3.amazonaws.com/path/to/image</image:loc>
</image:image>
<image:image>
<image:loc>https://s3.amazonaws.com/path/to/image2</image:loc>
<image:loc>httpss://s3.amazonaws.com/path/to/image2</image:loc>
<image:caption>Test Caption</image:caption>
<image:geo_location>Limerick, Ireland</image:geo_location>
<image:title>Test Title</image:title>
<image:license>http://www.license.com</image:license>
<image:license>https://www.license.com</image:license>
</image:image>
</url>
<url>
<loc>http://www.example.com/2</loc>
<loc>https://www.example.com/2</loc>
<image:image>
<image:loc>https://s3.amazonaws.com/path/to/image</image:loc>
<image:loc>httpss://s3.amazonaws.com/path/to/image</image:loc>

This comment has been minimized.

Copy link
@holtkamp

holtkamp Jul 26, 2017

Watch out here, too much httpsssss

This comment has been minimized.

Copy link
@ThePixelDeveloper

ThePixelDeveloper Jul 26, 2017

Author Owner

Whoops, that'll be me rushing something without looking 🙈

This comment has been minimized.

Copy link
@holtkamp

holtkamp Jul 26, 2017

😎

</image:image>
<image:image>
<image:loc>https://s3.amazonaws.com/path/to/image2</image:loc>
<image:loc>httpss://s3.amazonaws.com/path/to/image2</image:loc>
<image:caption>Test Caption</image:caption>
<image:geo_location>Limerick, Ireland</image:geo_location>
<image:title>Test Title</image:title>
<image:license>http://www.license.com</image:license>
<image:license>https://www.license.com</image:license>
</image:image>
</url>
</urlset>
XML;

$urlset = new Urlset();

$image2 = new Image('https://s3.amazonaws.com/path/to/image2');
$image2 = new Image('httpss://s3.amazonaws.com/path/to/image2');
$image2->setCaption('Test Caption');
$image2->setGeoLocation('Limerick, Ireland');
$image2->setTitle('Test Title');
$image2->setLicense('http://www.license.com');
$image2->setLicense('https://www.license.com');

$image = new Image('https://s3.amazonaws.com/path/to/image');
$image = new Image('httpss://s3.amazonaws.com/path/to/image');

$imageUrl = new Url('http://www.example.com/1');
$imageUrl = new Url('https://www.example.com/1');
$imageUrl->addSubElement($image);
$imageUrl->addSubElement($image2);

$imageUrl2 = new Url('http://www.example.com/2');
$imageUrl2 = new Url('https://www.example.com/2');
$imageUrl2->addSubElement($image);
$imageUrl2->addSubElement($image2);

Expand All @@ -101,44 +101,44 @@ function it_should_generate_a_sitemap_with_links()
{
$xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<urlset xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="https://www.w3.org/1999/xhtml">
<url>
<loc>http://www.example.com/english/</loc>
<xhtml:link rel="alternate" hreflang="de" href="http://www.example.com/deutsch/"/>
<xhtml:link rel="alternate" hreflang="de-ch" href="http://www.example.com/schweiz-deutsch/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://www.example.com/english/"/>
<loc>https://www.example.com/english/</loc>
<xhtml:link rel="alternate" hreflang="de" href="https://www.example.com/deutsch/"/>
<xhtml:link rel="alternate" hreflang="de-ch" href="https://www.example.com/schweiz-deutsch/"/>
<xhtml:link rel="alternate" hreflang="en" href="https://www.example.com/english/"/>
</url>
<url>
<loc>http://www.example.com/deutsch/</loc>
<xhtml:link rel="alternate" hreflang="en" href="http://www.example.com/english/"/>
<xhtml:link rel="alternate" hreflang="de-ch" href="http://www.example.com/schweiz-deutsch/"/>
<xhtml:link rel="alternate" hreflang="de" href="http://www.example.com/deutsch/"/>
<loc>https://www.example.com/deutsch/</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://www.example.com/english/"/>
<xhtml:link rel="alternate" hreflang="de-ch" href="https://www.example.com/schweiz-deutsch/"/>
<xhtml:link rel="alternate" hreflang="de" href="https://www.example.com/deutsch/"/>
</url>
<url>
<loc>http://www.example.com/schweiz-deutsch/</loc>
<xhtml:link rel="alternate" hreflang="de" href="http://www.example.com/deutsch/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://www.example.com/english/"/>
<xhtml:link rel="alternate" hreflang="de-ch" href="http://www.example.com/schweiz-deutsch/"/>
<loc>https://www.example.com/schweiz-deutsch/</loc>
<xhtml:link rel="alternate" hreflang="de" href="https://www.example.com/deutsch/"/>
<xhtml:link rel="alternate" hreflang="en" href="https://www.example.com/english/"/>
<xhtml:link rel="alternate" hreflang="de-ch" href="https://www.example.com/schweiz-deutsch/"/>
</url>
</urlset>
XML;
$urlset = new Urlset();
$url = new Url('http://www.example.com/english/');
$url->addSubElement(new Link('de', 'http://www.example.com/deutsch/'));
$url->addSubElement(new Link('de-ch', 'http://www.example.com/schweiz-deutsch/'));
$url->addSubElement(new Link('en', 'http://www.example.com/english/'));
$url = new Url('https://www.example.com/english/');
$url->addSubElement(new Link('de', 'https://www.example.com/deutsch/'));
$url->addSubElement(new Link('de-ch', 'https://www.example.com/schweiz-deutsch/'));
$url->addSubElement(new Link('en', 'https://www.example.com/english/'));
$urlset->addUrl($url);

$url = new Url('http://www.example.com/deutsch/');
$url->addSubElement(new Link('en', 'http://www.example.com/english/'));
$url->addSubElement(new Link('de-ch', 'http://www.example.com/schweiz-deutsch/'));
$url->addSubElement(new Link('de', 'http://www.example.com/deutsch/'));
$url = new Url('https://www.example.com/deutsch/');
$url->addSubElement(new Link('en', 'https://www.example.com/english/'));
$url->addSubElement(new Link('de-ch', 'https://www.example.com/schweiz-deutsch/'));
$url->addSubElement(new Link('de', 'https://www.example.com/deutsch/'));
$urlset->addUrl($url);

$url = new Url('http://www.example.com/schweiz-deutsch/');
$url->addSubElement(new Link('de', 'http://www.example.com/deutsch/'));
$url->addSubElement(new Link('en', 'http://www.example.com/english/'));
$url->addSubElement(new Link('de-ch', 'http://www.example.com/schweiz-deutsch/'));
$url = new Url('https://www.example.com/schweiz-deutsch/');
$url->addSubElement(new Link('de', 'https://www.example.com/deutsch/'));
$url->addSubElement(new Link('en', 'https://www.example.com/english/'));
$url->addSubElement(new Link('de-ch', 'https://www.example.com/schweiz-deutsch/'));
$urlset->addUrl($url);

$this->getOutput($urlset)->shouldReturn($xml);
Expand All @@ -149,21 +149,21 @@ function it_should_write_processing_instructions()
$xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/path/to/xslt/main-sitemap.xsl"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<urlset xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="https://www.w3.org/1999/xhtml">
<url>
<loc>http://www.example.com/english/</loc>
<xhtml:link rel="alternate" hreflang="de" href="http://www.example.com/deutsch/"/>
<xhtml:link rel="alternate" hreflang="de-ch" href="http://www.example.com/schweiz-deutsch/"/>
<xhtml:link rel="alternate" hreflang="en" href="http://www.example.com/english/"/>
<loc>https://www.example.com/english/</loc>
<xhtml:link rel="alternate" hreflang="de" href="https://www.example.com/deutsch/"/>
<xhtml:link rel="alternate" hreflang="de-ch" href="https://www.example.com/schweiz-deutsch/"/>
<xhtml:link rel="alternate" hreflang="en" href="https://www.example.com/english/"/>
</url>
</urlset>
XML;

$urlset = new Urlset();
$url = new Url('http://www.example.com/english/');
$url->addSubElement(new Link('de', 'http://www.example.com/deutsch/'));
$url->addSubElement(new Link('de-ch', 'http://www.example.com/schweiz-deutsch/'));
$url->addSubElement(new Link('en', 'http://www.example.com/english/'));
$url = new Url('https://www.example.com/english/');
$url->addSubElement(new Link('de', 'https://www.example.com/deutsch/'));
$url->addSubElement(new Link('de-ch', 'https://www.example.com/schweiz-deutsch/'));
$url->addSubElement(new Link('en', 'https://www.example.com/english/'));
$urlset->addUrl($url);

$this->addProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="/path/to/xslt/main-sitemap.xsl"');
Expand Down
4 changes: 2 additions & 2 deletions spec/SitemapSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SitemapSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('http://www.example.com/sitemap1.xml.gz');
$this->beConstructedWith('https://www.example.com/sitemap1.xml.gz');
}

function it_is_initializable()
Expand All @@ -19,7 +19,7 @@ function it_is_initializable()

function it_should_have_a_loc()
{
$this->getLoc()->shouldReturn('http://www.example.com/sitemap1.xml.gz');
$this->getLoc()->shouldReturn('https://www.example.com/sitemap1.xml.gz');
}

function it_should_have_a_last_mod()
Expand Down
2 changes: 1 addition & 1 deletion spec/Subelements/ImageSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ImageSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('http://www.example.com/');
$this->beConstructedWith('https://www.example.com/');
}

function it_is_initializable()
Expand Down
4 changes: 2 additions & 2 deletions spec/Subelements/LinkSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class LinkSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('en', 'http://www.example.com/');
$this->beConstructedWith('en', 'https://www.example.com/');
}

function it_is_initializable()
Expand All @@ -24,6 +24,6 @@ function it_should_return_en_for_hreflang()

function it_should_return_url_for_href()
{
$this->getHref()->shouldReturn('http://www.example.com/');
$this->getHref()->shouldReturn('https://www.example.com/');
}
}
4 changes: 2 additions & 2 deletions spec/UrlSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class UrlSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('http://www.example.com/');
$this->beConstructedWith('https://www.example.com/');
}

function it_is_initializable()
Expand All @@ -19,7 +19,7 @@ function it_is_initializable()

function it_should_have_a_loc()
{
$this->getLoc()->shouldReturn('http://www.example.com/');
$this->getLoc()->shouldReturn('https://www.example.com/');
}

function it_should_have_a_last_mod()
Expand Down
6 changes: 3 additions & 3 deletions spec/UrlsetSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ function it_should_return_the_urls_added(Url $url)
function it_should_only_append_attributes_once_for_each_subelement_type(XMLWriter $xmlWriter, Url $url, Image $image, Video $video)
{
$xmlWriter->startElement('urlset')->shouldBeCalled();
$xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance')->shouldBeCalled();
$xmlWriter->writeAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 ' . 'http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd')->shouldBeCalled();
$xmlWriter->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9')->shouldBeCalled();
$xmlWriter->writeAttribute('xmlns:xsi', 'https://www.w3.org/2001/XMLSchema-instance')->shouldBeCalled();
$xmlWriter->writeAttribute('xsi:schemaLocation', 'https://www.sitemaps.org/schemas/sitemap/0.9 ' . 'https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd')->shouldBeCalled();
$xmlWriter->writeAttribute('xmlns', 'https://www.sitemaps.org/schemas/sitemap/0.9')->shouldBeCalled();

$url->getSubelementsThatAppend()->willReturn([$image, $video]);
$this->appendSubelementAttribute($xmlWriter, $image)->shouldReturn(true);
Expand Down
8 changes: 4 additions & 4 deletions src/SitemapIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public function addSitemap(OutputInterface $sitemap)
public function generateXML(XMLWriter $XMLWriter)
{
$XMLWriter->startElement('sitemapindex');
$XMLWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$XMLWriter->writeAttribute('xmlns:xsi', 'https://www.w3.org/2001/XMLSchema-instance');

$XMLWriter->writeAttribute(
'xsi:schemaLocation',
'http://www.sitemaps.org/schemas/sitemap/0.9 ' .
'http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd'
'https://www.sitemaps.org/schemas/sitemap/0.9 ' .
'https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd'
);

$XMLWriter->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
$XMLWriter->writeAttribute('xmlns', 'https://www.sitemaps.org/schemas/sitemap/0.9');

foreach ($this->getSitemaps() as $sitemap) {
$sitemap->generateXML($XMLWriter);
Expand Down
2 changes: 1 addition & 1 deletion src/Subelements/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,6 @@ public function setLicense($license)
*/
public function appendAttributeToCollectionXML(XMLWriter $XMLWriter)
{
$XMLWriter->writeAttribute('xmlns:image', 'http://www.google.com/schemas/sitemap-image/1.1');
$XMLWriter->writeAttribute('xmlns:image', 'https://www.google.com/schemas/sitemap-image/1.1');
}
}
2 changes: 1 addition & 1 deletion src/Subelements/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function generateXML(XMLWriter $XMLWriter)
*/
public function appendAttributeToCollectionXML(XMLWriter $XMLWriter)
{
$XMLWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
$XMLWriter->writeAttribute('xmlns:xhtml', 'https://www.w3.org/1999/xhtml');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Subelements/Mobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Mobile implements OutputInterface, AppendAttributeInterface
*/
public function appendAttributeToCollectionXML(XMLWriter $XMLWriter)
{
$XMLWriter->writeAttribute('xmlns:mobile', 'http://www.google.com/schemas/sitemap-mobile/1.0');
$XMLWriter->writeAttribute('xmlns:mobile', 'https://www.google.com/schemas/sitemap-mobile/1.0');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Subelements/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function setKeywords($keywords)
*/
public function appendAttributeToCollectionXML(XMLWriter $XMLWriter)
{
$XMLWriter->writeAttribute('xmlns:news', 'http://www.google.com/schemas/sitemap-news/0.9');
$XMLWriter->writeAttribute('xmlns:news', 'https://www.google.com/schemas/sitemap-news/0.9');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Subelements/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Video implements OutputInterface, AppendAttributeInterface
/**
* The price to download or view the video in ISO 4217 format.
*
* @link http://en.wikipedia.org/wiki/ISO_4217
* @link https://en.wikipedia.org/wiki/ISO_4217
*
* @var string
*/
Expand Down Expand Up @@ -664,6 +664,6 @@ public function setLive($live)
*/
public function appendAttributeToCollectionXML(XMLWriter $XMLWriter)
{
$XMLWriter->writeAttribute('xmlns:video', 'http://www.google.com/schemas/sitemap-video/1.1');
$XMLWriter->writeAttribute('xmlns:video', 'https://www.google.com/schemas/sitemap-video/1.1');
}
}
8 changes: 4 additions & 4 deletions src/Urlset.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public function generateXML(XMLWriter $XMLWriter)
{
$XMLWriter->startElement('urlset');

$XMLWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$XMLWriter->writeAttribute('xmlns:xsi', 'https://www.w3.org/2001/XMLSchema-instance');

$XMLWriter->writeAttribute('xsi:schemaLocation',
'http://www.sitemaps.org/schemas/sitemap/0.9 ' .
'http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd');
'https://www.sitemaps.org/schemas/sitemap/0.9 ' .
'https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd');

$XMLWriter->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
$XMLWriter->writeAttribute('xmlns', 'https://www.sitemaps.org/schemas/sitemap/0.9');

foreach ($this->getUrls() as $url) {
foreach ($url->getSubelementsThatAppend() as $subelement) {
Expand Down

0 comments on commit 33733b9

Please sign in to comment.