Problem/Motivation

After upgrading to 8.x-1.0-beta9, we noticed that on certain pages, our custom webfonts were not loading. After much digging and head scratching, we tracked this down to the referrer metatag and its default value of no-referrer. The external font service we're using (Typography.com), expects a referrer value which it uses to check a list of acceptable domains. If this isn't present, it will return: 403 Forbidden.

This issue was only present on new entities or on entities that were just updated. It turns out that the new "referrer" metatag was only being added when a new revision was created. If reverted to a previous revision (prior to updating metatag), the fonts loaded without issue.

To solve for this across the site, the global value for referrer needed to be set to "Origin". Any revisions that had been made since installation needed to be manually set to Origin, since they were now overriding the default.

In my opinion, the key issue here is that the "Referrer" tag is added with or without interaction from a site admin. I believe this is because there is no means by which to leave it blank or otherwise off, since it is a select field and does not have an empty default option. Thus, installing the module enables the referrer metatag with the value of no-referrer.

Referrer metatag was added in issue: #2708511: Referrer metatag support in Drupal 8

Proposed resolution

Since Drupal 8 does not ship with this tag enabled, I think a reasonable solution would be to leave this field disabled unless otherwise instructed by a site admin.

Comments

chrisfree created an issue. See original summary.

damienmckenna’s picture

Status: Active » Closed (works as designed)

There is no default value for the "referrer" meta tag, please check your site's Metatag configurations (admin/config/search/metatag) to see where it's being set.

chrisfree’s picture

I tested this on a clean Drupal 8 install and realized the following:

Referrer config doesn't exist by default. However, saving any configuration will end up adding the referrer value because you cannot choose any empty value for the referrer field.

I could see how others might end up enabling this tag without realizing it. Or others, like myself, could inadvertently enable it without understanding it's implications.

When I upgraded to the latest beta (on the site that initially made me aware of this change) I did not alter any configuration, but our deployments do import config as a build step. Perhaps that alone will create the referrer config without any user interaction at all?

If I'm understanding correctly, there is no means by which to exclude any metatags that have a select field and do not contain an empty value option as their configuration field. Is that accurate? This would affect "Twitter Cards Type" and "Referrer" as far as I can tell.

damienmckenna’s picture

Title: Referrer Metatag Defaults Can Interfere with 3rd Party Integrations » Unable to not select the "Referrer" meta tag
Status: Closed (works as designed) » Active

Oh my! You are absolutely correct! I'm sorry about that.

So yeah, we need the selector to show an "empty" option for this so it won't be saved.

damienmckenna’s picture

chrisfree’s picture

Right on! I'll try and whip up a patch this afternoon.

chrisfree’s picture

Status: Active » Needs review
StatusFileSize
new1.2 KB

Whipped up a patch that adds empty values to both the referrer field as well as the Twitter Card Type. Tested without issue.

damienmckenna’s picture

Thanks! Do you think it'd be work going back and purging these values from existing values?

chrisfree’s picture

Do you mean wiping out any existing config related to these fields? If so, I would say no. We can't know for certain which users wanted the config and which didn't. Perhaps the best approach would be to add something to the readme in the next release?

markdorison’s picture

StatusFileSize
new1.2 KB

Seemed like there was an extra space after the array key. No functional changes.

damienmckenna’s picture

@chrisfree: Yeah, will definitely need a changenotice message for this.

@markdorison: Thanks.

chrisfree’s picture

@DamienMcKenna need help drafting something up? Or do you want to take this from here?

bedlam’s picture

Question: is it worth modifying the patch to use the select element's #empty_option and #empty_value properties?

damienmckenna’s picture

Status: Needs review » Needs work

@bedlam: Good call, thanks. Yes, it should.

chrisfree’s picture

Status: Needs work » Needs review
StatusFileSize
new1.72 KB

Updated patch. Good catch @bedlam. Now, can we get any more Chromatic developers in this thread?!

@DamienMcKenna let me know if you need anything else!

chrisfree’s picture

Ignore previous patch. Contained an extraneous line that should've been removed. Here is the one you want.

mmatsoo’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new29.29 KB

Applied the patch and the Referrer dropdown now includes the "- None -" option.

Referrer dropdown with None option

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks!

damienmckenna’s picture

Issue tags: +govcon2016

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

damienmckenna’s picture

FYI this was causing other problems, e.g. #2781541: Email modal content "breaks" when using metatag module.