I have created several page nodes containing javascript and PHP for presenting dynamic Flash charts.

When I search for content that returns one of these nodes, part of the node is returned, un-themed, with an error. It should instead be listing all the nodes containing the search words with snippets showing where the key words were found. The placement of the

directive does not seem to make a difference. Maybe there is an issue with putting all this Javascript into the node itself, but it seems to work fine otherwise.

Here is the website (search for "flash" to see the behavior):
http://simsmoke.org/search

Here is the full PHP- and Javascript-laden code of the node http://simsmoke.org/three_zone_mass_balance_model (which is being searched for with the "flash" keyword and generating the weird behavior when returned):

<p>
This tutorial is the third in a series that explores the mass balance model.  Here, you can explore a three-zone model.  Before using this tutorial, you should read the two previous tutorials containing <a href="/introduction_to_the_mass_balance_model">an introduction to the mass balance model</a> and an <a href="/exploring_a_two_zone_mass_balance_model">exploration of a two-zone model</a>.
</p>
		
<!--break-->

<script language="JavaScript" src="charts/tigraslider.js"></script>
	<script language="JavaScript">
	var A_TPL = {
		'b_vertical' : true,
		'b_watch': true,
		'n_controlWidth': 18,
		'n_controlHeight': 120,
		'n_sliderWidth': 18,
		'n_sliderHeight': 40,
		'n_pathLeft' : 0,
		'n_pathTop' : 1,
		'n_pathLength' : 78,
		's_imgControl': 'charts/img/sldr2v_bg.gif',
		's_imgSlider': 'charts/img/sldr2v_sl.gif',
		'n_zIndex': 1
	}
	var A_INIT1a = {
		's_name': 'Volume1',
		'n_minValue' : 10,
		'n_maxValue' : 500,
		'n_value' : 100,
		'n_step' : 10
	}
	
	var A_INIT1b = {
		's_name': 'Volume2',
		'n_minValue' : 10,
		'n_maxValue' : 500,
		'n_value' : 50,
		'n_step' : 10
	}
	
	var A_INIT1c = {
		's_name': 'Volume3',
		'n_minValue' : 10,
		'n_maxValue' : 500,
		'n_value' : 10,
		'n_step' : 10
	}


	var A_INIT2a = {
		's_name': 'Emissions',
		'n_minValue' : 100,
		'n_maxValue' : 1500,
		'n_value' : 1000,
		'n_step' : 100
	}

        var A_INIT2b = {
               's_name': 'Duration',
               'n_minValue' : 5,
               'n_maxValue' : 60,
               'n_value' : 10,
               'n_step' : 1
        }

	var A_INIT3a = {
		's_name': 'Flow12',
		'n_minValue' : 10,
		'n_maxValue' : 300,
		'n_value' : 100,
		'n_step' : 10
	}

	var A_INIT3b = {
		's_name': 'Flow13',
		'n_minValue' : 10,
		'n_maxValue' : 300,
		'n_value' : 50,
		'n_step' : 10
	}
	
	var A_INIT3c = {
		's_name': 'Flow23',
		'n_minValue' : 1,
		'n_maxValue' : 300,
		'n_value' : 1,
		'n_step' : 1
	}
	
	var A_INIT3d = {
		's_name': 'Flow10',
		'n_minValue' : 5,
		'n_maxValue' : 300,
		'n_value' : 100,
		'n_step' : 5
	}

	var A_INIT3e = {
		's_name': 'Flow20',
		'n_minValue' : 5,
		'n_maxValue' : 300,
		'n_value' : 50,
		'n_step' : 5
	}

	var A_INIT3f = {
		's_name': 'Flow30',
		'n_minValue' : 5,
		'n_maxValue' : 300,
		'n_value' : 10,
		'n_step' : 5
	}

	var A_INIT4 = {
		's_name': 'Deposition',
		'n_minValue' : 0.01,
		'n_maxValue' : 1,
		'n_value' : 0.1,
		'n_step' : 0.01
	}

	</script>


<script language="JavaScript">
function updatechart()
   {
     var vol1 = document.getElementById('Volume1');
     var vol2 = document.getElementById('Volume2');
     var vol3 = document.getElementById('Volume3');
     var em = document.getElementById('Emissions');
     var dur = document.getElementById('Duration');
     var flow12 = document.getElementById('Flow12');
     var flow13 = document.getElementById('Flow13');
     var flow23 = document.getElementById('Flow23');
     var flow10 = document.getElementById('Flow10');
     var flow20 = document.getElementById('Flow20');
     var flow30 = document.getElementById('Flow30');
     var dep = document.getElementById('Deposition');
     document.charts.SetVariable("update_url", "charts/threezone_update_1.php?volume1="+vol1.value+"&volume2="+vol2.value+"&volume3="+vol3.value+"&emissions="+em.value+"&duration="+dur.value+"&flow12="+flow12.value+"&flow13="+flow13.value+"&flow23="+flow23.value+"&flow10="+flow10.value+"&flow20="+flow20.value+"&flow30="+flow30.value+"&deposition="+dep.value+"&uniqueid="+Math.random());
   }
</script>

<p>For the present exercise you can explore a three-zone box model for air pollutant emissions.  The pollutant mass is emitted into the first zone (Room #1), but it can travel to the second and third zones at adjustable flow rates.  Pollutant mass is removed from both zones by ventilation or by deposition onto surfaces.  The emissions are assumed to be instantly mixed throughout the zones.    </p>

<p>For this exercise you can adjust the volumes of the spaces, the rate of mass emissions into the first space, the duration of the emissions, the air flow rate between the zones, the air flow rate between each of the zones and the outdoors, and the rate of pollutant deposition.</p>


Note that you need <a href="http://www.macromedia.com/software/flash/about/">Adobe Flash</a> to use the control panel.


<h2> The Control Panel </h2>

<p>Adjust the sliders on the right side to change the input parameters of the model.  When you release the mouse button, the area graph on the left will be updated to reflect the new parameter value.   </p>

<p>The graph on the left shows the minute-by-minute concentration times series of the pollutant in all three zones.  Note that the plots are overlaid with Room #2 positioned behind Room #1 and Room #3 behind Room #2.   Observe how the shapes of the three time series change as you adjust the parameters.  Please note that the upper limit of the Y axis may change to accomodate the full time series. </p>

<p>

<table border="10" bordercolor="#990000" bgcolor="#FFFFCC" cellpadding=10>

<tr>
<td>


<table>

<tr>
<th> Three-Zone Box Model, Source in Room #1 </th>

<th> Input Parameters </th>

</tr>


<tr>

<td>
<?php
//include charts.php to access the InsertChart function
include "charts/charts.php";
echo InsertChart ( "charts/charts.swf", "charts/charts_library",
"charts/threezonefirst.php",
640, 480, "FFFFCC" );
?>

</td>


<td>

<div onClick=updatechart()>

<table cellpadding="5" cellspacing="3" border="0" align="left">

<tr align="center">

<td align="center">
<input name="Volume1" id="Volume1" type="Text" size="3" style="text-align:center;border: 0;background-color:#FFFFCC;">
<script language="JavaScript">var vol = new slider(A_INIT1a, A_TPL);</script>
Vol 1<br> [m<sup>3</sup>]

</td>

<td align="center">
<input name="Volume2" id="Volume2" type="Text" size="3" style="text-align:center;border: 0;background-color:#FFFFCC;">
<script language="JavaScript">var vol = new slider(A_INIT1b, A_TPL);</script>
Vol 2<br> [m<sup>3</sup>]
</td>

<td align="center">
<input name="Volume3" id="Volume3" type="Text" size="3" style="text-align:center;border: 0;background-color:#FFFFCC;">
<script language="JavaScript">var vol = new slider(A_INIT1c, A_TPL);</script>

Vol 3<br> [m<sup>3</sup>]
</td>

<td align="center">
<input name="Emissions" id="Emissions" type="Text" size="3" style="text-align:center;border: 0;background-color:#FFFFCC;">
<script language="JavaScript">new slider(A_INIT2a, A_TPL);</script>
Emiss. <br> [&mu;g/min]
</td>

<td align="center">
<input name="Duration" id="Duration" type="Text" size="3" style="text-align:center;border: 0;background-color:#FFFFCC;">
<script language="JavaScript">new slider(A_INIT2b, A_TPL);</script>
Dur. <br>[min]
</td>

<td align="center">
<input name="Deposition" id="Deposition" type="Text" size="3" style="text-align:center;border: 0;background-color:#FFFFCC;">
<script language="JavaScript">new slider(A_INIT4, A_TPL);</script>
Dep. <br> [1/hr]
</td>

</tr>

<tr align="center">

<td align="center">
<input name="Flow12" id="Flow12" type="Text" size="3" style="text-align:center;border: 0;background-color:#FFFFCC;">
<script language="JavaScript">new slider(A_INIT3a, A_TPL);</script>
Flow 1-2<br> [m<sup>3</sup>/hr]
</td>

<td align="center">
<input name="Flow13" id="Flow13" type="Text" size="3" style="text-align:center;border: 0;background-color:#FFFFCC;">

<script language="JavaScript">new slider(A_INIT3b, A_TPL);</script>
Flow 1-3<br> [m<sup>3</sup>/hr]
</td>

<td align="center">
<input name="Flow23" id="Flow23" type="Text" size="3" style="text-align:center;border: 0;background-color:#FFFFCC;">
<script language="JavaScript">new slider(A_INIT3c, A_TPL);</script>
Flow 2-3<br> [m<sup>3</sup>/hr]

</td>


<td align="center">
<input name="Flow10" id="Flow10" type="Text" size="3" style="text-align:center;border: 0;background-color:#FFFFCC;">
<script language="JavaScript">new slider(A_INIT3d, A_TPL);</script>
Flow 1-0<br> [m<sup>3</sup>/hr]
</td>

<td align="center">
<input name="Flow20" id="Flow20" type="Text" size="3" style="text-align:center;border: 0;background-color:#FFFFCC;">
<script language="JavaScript">new slider(A_INIT3e, A_TPL);</script>

Flow 2-0<br> [m<sup>3</sup>/hr]
</td>

<td align="center">
<input name="Flow30" id="Flow30" type="Text" size="3" style="text-align:center;border: 0;background-color:#FFFFCC;">
<script language="JavaScript">new slider(A_INIT3f, A_TPL);</script>
Flow 3-0<br> [m<sup>3</sup>/hr]
</td>

</tr>

</table>

</div>

</td>

</tr>

</table>

</td>
</tr>

</table>

Note:  Flow 1-2 is equal to the air flow between Rooms #1 and #2.  Likewise for Flow 1-3 and Flow 2-3.  The flow is assumed to be the same in both directions (i.e., balanced).   Flow 1-0 is the air flow between Room #1 and the outdoors (balanced in both directions).   Likewise for Flow 2-0 and Flow 3-0.   The specified deposition rate is assumed to apply to all three rooms.   The surface to volume ratios of the rooms are both assumed to be 3 m<sup>-1</sup>.

</p>


<h2>  Questions </h2>

Here are some study questions that you might consider in your exploration of pollutant dynamics using the three-zone box model.

<ol>

<li>What layout in a real home might be realistically represented by three zones?</li>

<li>Adjust the volumes and air flows for the three zones to represent a layout you have in mind.   How much exposure might a person in one of the adjacent rooms to a smoker receive in the layout you have chosen?</li>

</ol>




Comments

robertDouglass’s picture

Version: 5.1 » 7.x-dev

Confirmed that not all code was stripped properly in D6 when indexing a slightly modified version of above node. It seems that determined misuse of the PHP filter will break search.

Note to ohzbees: this is a good case when you want to get your javascript out of the node body. Write a custom module that adds the javascript in a file: see drupal_add_js.

jhodgdon’s picture

Title: Search of Javascript- and PHP-laden nodes returns unexpected, unthemed partial node data » JavaScript inside node with PHP filter is not all stripped out

Looks like there is a bug here to fix... The original poster wants the dynamic PHP content to be generated, but the bug we need to fix is in #1, about the JS not being stripped out.

jhodgdon’s picture

jhodgdon’s picture

Version: 7.x-dev » 8.x-dev
Issue summary: View changes
Issue tags: +Needs backport to D7

I'm assuming this is still an issue in D8.

dawehner’s picture

Given there is no php filter in drupal 8 I would kind of disagree.

jhodgdon’s picture

Title: JavaScript inside node with PHP filter is not all stripped out » JavaScript inside node causes problems on search results page

Fixing title. It really doesn't have anything to do with the PHP filter. It has to do with the search results page not working if you have JavaScript in a node body. At least, I think that is the problem. Anyway, we should at least test that in D8 the given node body will be OK in search results.

jhodgdon’s picture

Title: JavaScript inside node causes problems on search results page » JavaScript inside node with PHP filter causes problems on search results page
Version: 8.x-dev » 7.x-dev
Issue tags: -Needs backport to D7

I am unable to reproduce any problems when putting JavaScript inside a node in D8. So, moving this back to D7 and perhaps it does have something to do with the PHP filter after all? I have no idea. Anyway, I do not think it is a D8 problem.