After update from 7.x-2.0-rc2 to 7.x-2.0 the sitemap looks strange on the https page variant. With strange I mean like in https://www.inforwijzer.nl/sitemap.xml. In Chrome I get a blank page, in FF I can see the site map but it is strangely formatted.

The http variant is fine and in fact Google seems to not have any problem with the https variant. So no big deal, but it's strange.

When going back to the module version 7.x-2.0-rc2 both http and https look the same.

Does anyone have a clue?

Files: 
CommentFileSizeAuthor
#19 xmlsitemap-relative_xsl_url-2244449-19.patch627 bytesPascalAnimateur
#12 2244449-followup.patch741 bytesDave Reid
#8 2244449-sitemap-xsl-protocol-relative.patch1.94 KBDave Reid
PASSED: [[SimpleTest]]: [MySQL] 525 pass(es). View
#6 2244449-4-protocolless-xsl-url-d6.patch690 bytesChris Burge
None View
#4 2244449-4-protocolless-xsl-url.patch690 bytesChris Burge
PASSED: [[SimpleTest]]: [MySQL] 525 pass(es). View

Comments

quicksketch’s picture

Project: Webform » XML sitemap
Version: 7.x-3.20 » 7.x-2.0

Looks like this was added to the wrong queue? It doesn't sound like this has to do with Webform, so I'm moving to the XML Sitemap queue.

philsward’s picture

Ran into the same issue. Doing some digging between a site with an older xmlsitemap version and a different site with the 2.0 version (both are https), I noticed the following differences between the two in the sitemap.xml source:

Older xmlsitemap

<?xml-stylesheet type="text/xsl" href="/sitemap.xsl"?>

xmlsitemap 2.0

<?xml-stylesheet type="text/xsl" href="https://www.examplesite.com/sitemap.xsl"?>

The 2.0 version inserts the https into the URL...

What I did as a workaround to make it work, was simply add the following into secure pages "include" list. (I only secure certain pages)

sitemap.x*

Once I added the sitemap.x* into the include list and refreshed the sitemap.xml page, it showed the human version of the sitemap.

Long story short, the way the URL is handled in 2.0 for the .xsl file, it is adding the entire host URI.

Chris Burge’s picture

I can confirm your observation. It is caused by #1276232: wrong stylesheet with multiple domain xmlsitemaps, which was included with 7.x-2.0.

Chris Burge’s picture

Status: Active » Needs review
FileSize
690 bytes
PASSED: [[SimpleTest]]: [MySQL] 525 pass(es). View

When the XSL file is included in the generated markup, the module uses the 'xmlsitemap_base_url' variable to generate the file's URL. The 'xmlsitemap_base_url' variable is required to specify a protocol in order to pass as a valid URL.

As a result, if a Drupal instance is configured with 'xmlsitemap_base_url' = 'http://example.com', then the XSL URL will be 'http://example.com/sitemap.xsl' in all instances, including when 'sitemap.xml' is loaded in HTTPS. In this case Firefox and Chrome will refuse to load the page.

I've attached a patch to address this issue. When generating the XSL file's URL, it removes the protocol and replaces it with '//' to designate a protocol-less URL.

Chris Burge’s picture

Title: Strange sitemap on HTTPS after update to 7.x-2.0 » Use Protocol-less URL for XSL File
Chris Burge’s picture

Version: 7.x-2.0 » 6.x-2.x-dev
FileSize
690 bytes
None View

Drupal 6 version of patch. Switching to 6.x-2.x-dev for tests.

Chris Burge’s picture

Version: 6.x-2.x-dev » 7.x-2.0

6.x-2.x branch tests are failing, so patch test is set to postponed. Setting issue back to 7.x-2.0

Dave Reid’s picture

Version: 7.x-2.0 » 7.x-2.x-dev
FileSize
1.94 KB
PASSED: [[SimpleTest]]: [MySQL] 525 pass(es). View

Tweaked this a bit to help re-use some code elsewhere. Tested and confirmed it resolves issues using both HTTP and HTTPS.

Dave Reid’s picture

Version: 7.x-2.x-dev » 8.x-1.x-dev
Status: Needs review » Patch (to be ported)

Committed to both 7.x-2.x and 6.x-2.x. Needs to be ported to 8.x-1.x.

  • Dave Reid committed 83b9e41 on 6.x-2.x
    Issue #2244449 by Chris Burge, Dave Reid, philsward, ecvandenberg: Use...

  • Dave Reid committed edf2d69 on
    Issue #2244449 by Chris Burge, Dave Reid, philsward, ecvandenberg: Use...
Dave Reid’s picture

FileSize
741 bytes

Patch in #9 caused a regression with sitemap index generation, so added a follow-up commit to 7.x-2.x and 6.x-2.x. Patch provided if anyone needs it.

  • Dave Reid committed cf0873c on 7.x-2.x
    Issue #2244449: Fixed regression generating sitemap index links.
    

  • Dave Reid committed 7bb64cb on
    Issue #2244449: Fixed regression generating sitemap index links.
    
Chris Burge’s picture

@Dave Reid - Thanks for moving this issue along!

philsward’s picture

Just updated to 2.1 and ran into the issue of:

Error loading stylesheet: A network error occurred loading an XSLT stylesheet:

Turns out my Default base URL setting was incorrect. Is there any way the error message can point to this as the fix? There will be a handful of people out there getting that error page with no idea how to fix it. Let me know if I need to create a new issue. (Wishing I had tested this patch before now...)

Haven't tested on https yet, so no feedback in that area.

ecvandenberg’s picture

As stated in #16 I also notice the error loading stylesheet.

I also use Secure Pages (7.x-1.0-beta2). As a work around for this issue (https://www.drupal.org/node/2244449) I configured Secure Pages so that the page mydomein/sitemap.xml was shown unsecured (http).

With the update to XML sitemap 7.x-2.1 the unsecured sitemap gives an error loading stylesheet. Although Google Webmasters does not seem to have a problem with it, so no big deal.

I now configured Secure Pages to also secure the sitemap.xml page. Now the sitemap is shown, but without a stylesheet.

jmdorian’s picture

Version: 8.x-1.x-dev » 7.x-2.x-dev

Why not use the relative path to stylesheet.xsl? For example, replace

<?php
$this->writePi('xml-stylesheet', 'type="text/xsl" href="' . $this->getSitemapUrl('sitemap.xsl', array('protocol_relative' => TRUE)) . '"');
?>

with

<?php
$this->writePi('xml-stylesheet', 'type="text/xsl" href="' . $this->getSitemapUrl('sitemap.xsl', array('absolute' => FALSE)) . '"');
?>
PascalAnimateur’s picture

Here's a patch implementing solution #18 which works in my case (was having problems with language prefix not being used on english sitemap.xsl)

interdruper’s picture

#19 works for me.

gaurav.bajpai’s picture

#19 works for me too, Thanks.

millerrs’s picture

Can confirm #19 works.