http://tools.ietf.org/html/rfc4329#section-7

We should only change this in the .htaccess file and not in the script tags as explained here: http://stackoverflow.com/questions/9664282/difference-between-applicatio...

Note that using application/javascript in the type attribute of a script element will cause the script to be ignored (as being in an unknown language) in some older browsers. Either continue to use text/javascript there or omit the attribute entirely (which is permitted in HTML 5).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeytown2’s picture

Status: Active » Needs review
FileSize
504 bytes
mikeytown2’s picture

pedrocorse’s picture

hello
where do you add the line: AddType application/javascript .js ?
because I always message: "The web servers configuration will need to be adjusted. Was looking for application/javascript, actually got text/javascript. You might need to apply the drupal core patch located here https://drupal.org/node/2193333#comment-8469991."

I add the line after and replace the line "RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]" by "RewriteRule \.js\.gz$ - [T=application/javascript,E=no-gzip:1]"

I do not understand why I always error

mikeytown2’s picture

where do you add the line: AddType application/javascript .js ?

Add it at the very bottom of your .htaccess file.

RaulMuroc’s picture

To me this patch doesn't solve anything :S It stills shows the same error in advagg.

Thank you.

mikeytown2’s picture

@RaulMuroc
Have you ran update.php and completed the AdvAgg updates? Have you restarted apache (shouldn't have to do but never know)? If yes, open an issue in the AdvAgg issue queue and I'll do my best to figure out the issue :)

Also noted is have you set AllowOverride None in your httpd.conf file? If so changing the .htaccess file might not fix this as apache may no longer be reading info from drupal's core .htaccess file depending on how you have it setup.
More info: https://groups.drupal.org/node/22864

RaulMuroc’s picture

Status: Needs review » Fixed

@mikeytown2, thank you. Apparently the problem was to have the "AllowOverride None" active. Deleted it and restarted apache and everything works cool.

Thanks.

mikeytown2’s picture

Status: Fixed » Reviewed & tested by the community

This patch has not been committed to core yet, thus it has not been fixed. Marking this as RTBC since you have confirmed that this patch does fix this issue.

RaulMuroc’s picture

It appeared back the error suddenly after a cron run.

That's all explanation I have :(

mikeytown2’s picture

@RaulMuroc
Your httpd conf isn't setup ideally. Use include
http://drupal.stackexchange.com/questions/108301/adding-htaccess-within-...

RaulMuroc’s picture

Yes it is, cuz this site is working 5 years without problems.

messiahcide’s picture

How would one fix this error without access to httpd conf, after applying the patch and receiving the same error?

mikeytown2’s picture

@messiahcide
I think you're out of luck if that is the case. If access to httpd conf is not granted and changes to .htaccess don't do anything, then I'm afraid there is nothing that can you can directly do. Asking your hosting provider for help as to why .htaccess changes are not happening would be the next step to take.

David_Rothstein’s picture

Version: 7.x-dev » 8.x-dev
Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs backport to D7

I think a change like this needs some more reviews and testing across browsers/servers to make sure it's OK.

The patch also applies to Drupal 8, so I assume the same issue exists there...

RaulMuroc’s picture

Again, the patch doesn't do anything. Today fresh D7 installation with latest version of advagg, patch applied. Nothing, the warning stays.

srobert72’s picture

I have the same problem, the warnings never disappear no matter what I do. But I think I found the reason.

I use CDN module, so CSS&JS are delivered to browser by a CDN server and not my Drupal server.
In the warning report "Adv CSS/JS Agg - gzip" I see an URL to the CDN server and not my Drupal server.
So I think the test reports errors about the CDN server and not my Drupal server.
I can change all I want on my server the result will never change.

So I think the test should only be done on the Drupal server, bypassing the rewrites of CDN module.

To be undoubted I desactivate CDN module... and warnings all disappear.

srobert72’s picture

FileSize
19.4 KB

One workaround is to disable CDN for CSS&JS files.
Go to admin/config/development/cdn/details in CDN mapping
Remove *.js and *.css pattern
Clear All Cache and go back to admin/reports : All is perfect !!

RaulMuroc’s picture

But then I lose the advantages of using a CDN (specially performance and/or scalability)

srobert72’s picture

@RaulMuroc
Yes but only for CSS & JS files and you can continue to use CDN for images and all others files.
CSS&JS are a little volume compare to others files.

Status: Needs review » Needs work

The last submitted patch, 2: drupal-2193333-2-follow-rfc-4329.patch, failed testing.

mikeytown2’s picture

Status: Needs work » Needs review
FileSize
795 bytes

Re rolled as .htaccess changed in core recently.

mikeytown2’s picture

#22 passed; I would like to RTBC this.

For people wondering why this isn't working with the patch applied if you've imported all the drupal .htaccess rules into httpd.conf; then you'll need to import these changes as well. If you're using include inside httpd.conf like this: http://drupal.stackexchange.com/questions/108301/adding-htaccess-within-... then you'll need to restart apache. If this is coming from a CDN and you have zero control over the headers then simply ignore this warning coming from AdvAgg. Means the CDN is not following the current RFC for .js file but all browsers still work so you can ignore the warning.

drupalnewie @berfi’s picture

Hi guys! i receive an error in my drupal 7 status page which looks like the problem in this scope:

"Adv CSS/JS Agg - Content-Type The wrong Content-Type is being sent by your web server.
The web servers configuration will need to be adjusted. Was looking for application/javascript, actually got application/x-javascript. You might need to apply the drupal core patch located here https://drupal.org/node/2193333#comment-8469991."

My webserver is nginx, and i added to the configuration to support application/javascript but, it has not solved my problem.

Will these solution helps drupal 7.34?

Br

drupalnewie @berfi’s picture

Hi guys!

I solved the problem by change the application/x-javascript to application/javascript in nginx mimetype file.

thanks

mgifford’s picture

re-uploading for bots.

droplet’s picture

We may have to add gzip to both MIME type. It's all common usage.


+++ b/.htaccess
@@ -171,3 +171,6 @@ DirectoryIndex index.php index.html index.htm
+# Follow RFC 4329; use application/javascript for .js files.

this line may not safe to use when the module is missing. let wrap it with IfMoudle..etc

droplet’s picture

droplet’s picture

Strange, d.org taken my old upload ? adding spaces

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

droplet’s picture

Can I sign it off myself? Patch #29 is taken from well-tested HTML5 boilerplate and it almost same as #26. #23 has RTBC.

droplet’s picture

Status: Needs review » Reviewed & tested by the community
mikeytown2’s picture

Also agree that #29 is RTBC. Wrapping #22 in IfModule check makes total sense - https://httpd.apache.org/docs/2.4/mod/mod_mime.html#addtype

DamienMcKenna’s picture

There was an errant space at the end of the file, this removes it. The patch also (mostly) cleanly applied to D7 and 8.2.x

Does this still fit in the realm of a change for 8.1.x? The patch applies to both 8.1.x and 8.2.x.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 34: drupal-n2193333-34-d8.patch, failed testing.

dinarcon’s picture

Issue tags: +Needs reroll

This needs a reroll after modifications to the .htaccess file from SA-CORE-2016-003 (8.1.7)

costellofax’s picture

I'm working on the reroll as part of #D4DBoston sprint

costellofax’s picture

Status: Needs work » Needs review
FileSize
782 bytes

This is the reroll on 8.1.x

dinarcon’s picture

Thank you @costellofax for your work on this issue! I have tested the patch in #38 and it applies cleanly for 8.1.x and 8.2.x. Let's see what the test bot says. @DamienMcKenna's patch from #34 applies cleanly for 7.x.

Status: Needs review » Needs work

The last submitted patch, 38: follow_rfc_4329_use-2193333-38.patch, failed testing.

dinarcon’s picture

Status: Needs work » Needs review

mmm the tests that are failing do not seem to be related with the changes we are making. Queue for retesting.

dinarcon’s picture

Issue tags: -Needs reroll

Removing the "Needs reroll" tag as this has been address already.

costellofax’s picture

Thanks @dinarcon !!

dinarcon’s picture

Status: Needs review » Reviewed & tested by the community

The tests have passed. Yay! I have already tested this (#39). Marking RTBC. Thanks to everyone who worked on this issue!

The last submitted patch, 34: drupal-n2193333-34-d7.patch, failed testing.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/.htaccess
@@ -187,3 +187,9 @@ AddEncoding gzip svgz
+<IfModule mod_mime.c>
+  # Normalize to standard type.
+  # https://tools.ietf.org/html/rfc4329#section-7.2
+  AddType application/javascript .js
+</IfModule>

I don't think we should be doing this. Or we could have it commented out. I think most Apache servers are configured correctly so this is just busy work. Even the Apache that comes installed on every Mac is configured correctly. And if we're going to do this one - why stop here - sets a weird precedent.

The other change looks fine.

DamienMcKenna’s picture

How's about something like this?

DamienMcKenna’s picture

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

ZeiP’s picture

To me the change looks OK & works properly for 8.3.x as well with the patch in #47. However, I think the comment in #46 still applies: There's little point in adding the MIME type declaration commented-out – if we want to add it, then why not add it effectively? I do agree with @alexpott that declaring only the Javascript MIME type separately in .htaccess seems a bit weird, and if there aren't many proven cases in which the proper MIME type is missing from server configuration, it's busy work and shouldn't be done.

So IMO the patch should only change the RewriteRule.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

ZeiP’s picture

The issue's been stale for a few months, so here's the patch containing only the RewriteRule per my/alexpott's suggestion, please review.

mikeytown2’s picture

Status: Needs review » Reviewed & tested by the community

And we're back to my patch from #1

droplet’s picture

@mikeytown2, Are you sure you can RTBC your own patch then? 😆🤣😜

xjm’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs subsystem maintainer review, +Needs framework manager review, +Security

Hm this is a small thing that could have significant implications. I'd like to have the JS subsystem maintainers sign off on this one, and the framework managers. I pinged @drpal for a look and I see @droplet is following as well. Thanks!

dawehner’s picture

Just out of couristy I was trying to figure out whether IIS has support for a similar configuration and they do: https://docs.microsoft.com/en-us/iis/configuration/system.webserver/stat...
Their default behaviour is unknown though ...

What do other systems do?

  • Wordpress: https://codex.wordpress.org/htaccess (Note; This documentation doesn't yet mention application/javascript)
  • NodeJS: Express.static :
    $ curl -v http://localhost:5999/media/foo.js
    *   Trying ::1...
    * TCP_NODELAY set
    * Connected to localhost (::1) port 5999 (#0)
    > GET /media/foo.js HTTP/1.1
    > Host: localhost:5999
    > User-Agent: curl/7.54.0
    > Accept: */*
    >
    < HTTP/1.1 200 OK
    < X-Powered-By: Express
    < Accept-Ranges: bytes
    < Cache-Control: public, max-age=0
    < Last-Modified: Mon, 18 Sep 2017 09:55:19 GMT
    < ETag: W/"0-15e9469db58"
    < Content-Type: application/javascript
    < Content-Length: 0
    < Date: Mon, 18 Sep 2017 09:56:18 GMT
    < Connection: keep-alive
    <
    * Connection #0 to host localhost left intact
    
droplet’s picture

@dawehner,

IIS has no ZIP redirection in CORE and WP has no rewrite URL for ZIP things also. So they're both following the server configs. (ON-FLY-ZIPPING)

and I think NodeJS (and nginx) just replace the resource in the middleware. They won't change request/response Content-Type. [I can be wrong :)]

Not sure if it explains

droplet’s picture

and you should pass accept gzip to CURL:

curl -H "Accept-Encoding: gzip" -I http://drupal-site/sites/default/files/js/supppper_long_name.js

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

xjm’s picture

Version: 9.0.x-dev » 9.1.x-dev

I think there's some risk of disruption here, so it would probably be a minor-only change. Since 8.9.x and 9.0.x are now in beta, I'm moving this to 9.1.x. Thanks!

nod_’s picture

Status: Needs review » Postponed (maintainer needs more info)

Like alexpott said in #46 is this even still an issue? not touching anything the mime type is correct on my end, without this patch. Can we have a exemple of a setup where this problem happens before looking at the patch?

droplet’s picture

The patch is outdated BTW. After 3 years, it should be text/javascript again. LOL.

History Is Written by the Victors. 🤐🤐🤐

nod_’s picture

haha, that's a good one. Got a reference about this? wasn't aware we should be back on text/javascript :p

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

pameeela’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)
Issue tags: -Needs backport to D7, -Quick fix, -Novice, -Needs subsystem maintainer review, -Needs framework manager review, -Security +Bug Smash Initiative

https://datatracker.ietf.org/doc/html/draft-ietf-dispatch-javascript-mjs...

Finally, the [HTML] specification is using text/javascript as the default media type of ECMAScript when preparing script tags; therefore, text/javascript has been moved intended usage from OBSOLETE to COMMON.