The DNS Prefetch meta tag is being generated as

<link rel="dns-prefetch" href="//img1.mycdn.com http" />

I believe this should be
<link rel="dns-prefetch" href="http://img1.gusagusa.com" />

Not sure if its an allowed format or the url is being malformed. Happening on 2 individual sites that use CDN module for a sub-domain cdn

CommentFileSizeAuthor
#7 cdn-malformed-dns-prefetch-1826816.diff481 bytessaitanay
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Assigned: Unassigned » Wim Leers
Category: bug » support
Status: Active » Closed (works as designed)

That's actually correct; it's a protocol-relative URL :) (Makes sure it always works, for HTTP- and HTTPS-served pages; prevents mixed content warnings.)

See e.g. http://paulirish.com/2010/the-protocol-relative-url/

Wim Leers’s picture

Status: Closed (works as designed) » Fixed
Wim Leers’s picture

Title: Malformed dns-prefetch tag » Malformed dns-prefetch tag?
saitanay’s picture

Status: Fixed » Needs work

well, just one clarification

i understand that avoiding http before the url is fine.

but placing the same at the end of the url, separated by a space, is it also designed so? i could not find any example in such format, nor in the provided link. Apologoes in advance if this is not a bug.

<link rel="dns-prefetch" href="//img1.mycdn.com http" />

the "http" after mycdn.com is what i am talking about,.

saitanay’s picture

cdn mapping
http://img1.mydomain.com http://img2.mydomain.com http://img3.mydomain.com|.css .jpg .jpeg .png .gif

saitanay’s picture

did some debugging

the trailing http is being addded to the domain here at

 if (strpos($line, '|') !== FALSE) {
        $parts = explode('|', $line);
        $domains[] = parse_url(trim($parts[0]), PHP_URL_HOST);
      }

This happens when there are multiple domains mentioned in the same line

Either the code must be modified to handle multiple domains in the same line or the documentation in advanced_help should be updated , removing the example of mentioning multiple domains in same line

Quote from advanced help of cdn module

This would serve CSS and JS files from CDN A, images from either CDN B or C and everything else from CDN C: 
http://cdn-a.com|.css .js
http://cdn-b.com http://cdn-c.com|.jpg .jpeg .png
http://cdn-c.com

As mentioned in the above advanced_help, if the below format is used, then the http from the second domain is being added to the end of first domain and the dns prefetch tag is shown incorrect..
http://cdn-b.com http://cdn-c.com|.jpg .jpeg .png

saitanay’s picture

attached is a patch to the advanced help
its an svn diff though

Wim Leers’s picture

Category: support » bug
Status: Needs work » Active

#4: wow, no, that's definitely a bug. But I'm not seeing that on either http://wimleers.com (D7) nor http://driverpacks.net (D6).

Congrats, you've found a bug. I'll make sure to add a unit test for this.

Wim Leers’s picture

Title: Malformed dns-prefetch tag? » Malformed dns-prefetch tag when using CDN's "auto-balance over multiple CDNs" feature
saitanay’s picture

//#4: wow, no, that's definitely a bug. But I'm not seeing that on either http://wimleers.com (D7) nor http://driverpacks.net (D6).

I believe you are not seeing the issue on mentioned sites because they have the domains mapped in multiple lines

The issue seems to happen when there is more than 1 domain in each line of the CDN mapping ,. example:
http://img1.mydomain.com http://img2.mydomain.com http://img3.mydomain.com|.css .jpg .jpeg .png .gif

This can be avoided by

http://img1.mydomain.com|.css .jpg .jpeg .png .gif
http://img2.mydomain.com|.css .jpg .jpeg .png .gif
http://img3.mydomain.com|.css .jpg .jpeg .png .gif

This could be either fixed in the code,. or the advanced help could be updated removing the example of mapping multiple domains in single line

Wim Leers’s picture

Yep, as I said, you've found a bug. I should've worded it more clearly. I'm going to add a unit test to reproduce it and to ensure no regressions occur. Thanks for the detailed report! :)

If you want to fix this as fast as possible, please contribute a unit test!

Wim Leers’s picture

Status: Active » Closed (duplicate)

So… this was actually already fixed in 7.x-2.x a long time ago, along with extensive tests. :) Upgrade to the dev snapshot or to the upcoming 2.6 release and you won't experience this again

Specifically, it was fixed in this commit: http://drupalcode.org/project/cdn.git/commitdiff/63537efafdc6d345a30c11b....

See #1593930: cdn_get_domains() is broken for auto-balancing when using protocol-relative domains: fix + tighten tests.

Wim Leers’s picture

Issue summary: View changes

Add code tags.