Search indexing should Ignore javascript in <SCRIPT> tags

douggreen - May 11, 2008 - 16:04
Project:Drupal
Version:7.x-dev
Component:search.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Description

The search engine is indexing javascript inside of <SCRIPT> tags. See #257076.

The solution is to put script javascript inside an HTML comment. This is what we had to do in the 1990's when some browsers didn't support script. And I think it's still good practice.

<script><!-- --></script>

But the search engine should know that some people don't write good HTML, and should know to just skip these.

#1

douggreen - May 11, 2008 - 17:46
Status:active» needs work

It appears that drupal_add_js inline is not doing this, and I think it should. So a first step, is to get our own HTML to write the javascript inside an HTML comment.

AttachmentSize
257196.patch 1.15 KB

#2

douggreen - May 11, 2008 - 18:07

Although W3C says this works, this blog says that it doesn't. And the patch seems to break javascript on FF2. Guess it's back to just ignoring this in indexing.

#3

douggreen - May 11, 2008 - 20:41
Status:needs work» needs review

This method (<!-- -->) does work, ignore comment #2. The attached patch fixes the problem inherent in drupal_add_js, and adds a test case.

AttachmentSize
257196.patch 2.68 KB

#4

lilou - September 28, 2008 - 21:51
Status:needs review» needs work

CNW since #158992: Inline JavaScript is XHTML invalid commit.

 
 

Drupal is a registered trademark of Dries Buytaert.