Welcome to Geeklog, Anonymous Wednesday, November 27 2024 @ 12:50 pm EST
Geeklog Forums
Problem with multiple script tags in pages or stories
Status: offline
Stu1879
Forum User
Newbie
Registered: 05/04/15
Posts: 5
Since upgrading from 2.1.1 to 2.1.2, I am having problems with script tags in my content. Here is a minimal repro case:
Create a story with the following body content:
<script>foo</script>
<script>bar</script>
Save the story and navigate to it. If the page source is viewed, the contents of the story body appear as:
<script>foo</script>
<script>foo</script>
Basically the contents of the first script tag are copied into all the subsequent tags.
The issue is appearing for me in a static page with 3 script tags driving a javascript gallery, and in this case the same mangling is also happening when I save the page via the (basic) editor. If I restore the correct content by editing the DB directly then it appears correctly in the editor until it is saved using the editor, at which point it gets mangled. The mangled version appears in the output HTML every time.
As far as I know, I have all HTML filtering turned off.
Any ideas what is happening?
Create a story with the following body content:
Text Formatted Code
<script>foo</script>
<script>bar</script>
Save the story and navigate to it. If the page source is viewed, the contents of the story body appear as:
Text Formatted Code
<script>foo</script>
<script>foo</script>
Basically the contents of the first script tag are copied into all the subsequent tags.
The issue is appearing for me in a static page with 3 script tags driving a javascript gallery, and in this case the same mangling is also happening when I save the page via the (basic) editor. If I restore the correct content by editing the DB directly then it appears correctly in the editor until it is saved using the editor, at which point it gets mangled. The mangled version appears in the output HTML every time.
As far as I know, I have all HTML filtering turned off.
Any ideas what is happening?
13
13
Quote
Status: offline
Stu1879
Forum User
Newbie
Registered: 05/04/15
Posts: 5
Bug report submitted: https://github.com/Geeklog-Core/geeklog/issues/783
21
18
Quote
Status: offline
Laugh
Site Admin
Admin
Registered: 09/27/05
Posts: 1470
Location:Canada
Note: this was fixed with changeset:
https://github.com/Geeklog-Core/geeklog/commit/df59c80911a30b38b222878ec1dd9fd104c4d6db
To fix you will have to download the latest copy of the gltext.class.php file from GitHub above (system/classes/gltext.class.php).
One of the Geeklog Core Developers.
https://github.com/Geeklog-Core/geeklog/commit/df59c80911a30b38b222878ec1dd9fd104c4d6db
To fix you will have to download the latest copy of the gltext.class.php file from GitHub above (system/classes/gltext.class.php).
One of the Geeklog Core Developers.
21
18
Quote
Status: offline
ivy
Forum User
Full Member
Registered: 11/25/04
Posts: 314
Location:Tokyo Japan
Autotags does not work in the scrpt tag.
[xxxx:xxx]
</script>
Geeklog Japan https://www.geeklog.jp
Text Formatted Code
<script>[xxxx:xxx]
</script>
Geeklog Japan https://www.geeklog.jp
12
17
Quote
Status: offline
ivy
Forum User
Full Member
Registered: 11/25/04
Posts: 314
Location:Tokyo Japan
Staticpage.
example:
google.load("visualization", "1", { packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([ [ "Element", "Price", { role: "style" }, { role: "annotation" } ],
[ "Average", [databox:math method:average type_id:1 templatesetvar:price category_code:type1102 round precision:0 numberformat:no], "#eeee66", '[databox:math method:average type_id:1 templatesetvar:price category_code:type1102 roundprecision:0 numberformat:yes permission:ignore] yen'],
[ "Max", [databox:math method:max type_id:1 templatesetvar:price category_code:type1102 roundprecision:0 numberformat:no], "#cccccc", '[databox:math method:max type_id:1 templatesetvar:price category_code:type1102 roundprecision:0 numberformat:yes permission:ignore] yen'],
[ "Low", [databox:math method:min type_id:1 templatesetvar:price category_code:type1102 roundprecision:0 numberformat:no], "#666666", '[databox:math method:min type_id:1 templatesetvar:price category_code:type1102 roundprecision:0 numberformat:yes permission:ignore] yen'],
]);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1, { calc: "stringify", sourceColumn: 1, type: "string", role: "annotation" }, 2]);
var options = {
title: "Price",
width: 400,
height: 300,
bar: {groupWidth: "95%"},
legend: { position: "none" },
};
var chart = new google.visualization.BarChart(document.getElementById("barchart_values"));
chart.draw(view, options);
}
</script>
<div id="barchart_values" class="uk-container-center" style="margin:0 auto; "></div>
Geeklog Japan https://www.geeklog.jp
example:
Text Formatted Code
<script type="text/javascript">google.load("visualization", "1", { packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([ [ "Element", "Price", { role: "style" }, { role: "annotation" } ],
[ "Average", [databox:math method:average type_id:1 templatesetvar:price category_code:type1102 round precision:0 numberformat:no], "#eeee66", '[databox:math method:average type_id:1 templatesetvar:price category_code:type1102 roundprecision:0 numberformat:yes permission:ignore] yen'],
[ "Max", [databox:math method:max type_id:1 templatesetvar:price category_code:type1102 roundprecision:0 numberformat:no], "#cccccc", '[databox:math method:max type_id:1 templatesetvar:price category_code:type1102 roundprecision:0 numberformat:yes permission:ignore] yen'],
[ "Low", [databox:math method:min type_id:1 templatesetvar:price category_code:type1102 roundprecision:0 numberformat:no], "#666666", '[databox:math method:min type_id:1 templatesetvar:price category_code:type1102 roundprecision:0 numberformat:yes permission:ignore] yen'],
]);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1, { calc: "stringify", sourceColumn: 1, type: "string", role: "annotation" }, 2]);
var options = {
title: "Price",
width: 400,
height: 300,
bar: {groupWidth: "95%"},
legend: { position: "none" },
};
var chart = new google.visualization.BarChart(document.getElementById("barchart_values"));
chart.draw(view, options);
}
</script>
<div id="barchart_values" class="uk-container-center" style="margin:0 auto; "></div>
Geeklog Japan https://www.geeklog.jp
18
12
Quote
Status: offline
Laugh
Site Admin
Admin
Registered: 09/27/05
Posts: 1470
Location:Canada
I found where it is probably doing it. I didn't update this part of the code but I am assuming there is some reason why it is being done. So this fix may cause issues elsewhere...
In lib-plugins.php look at the function PLG_replaceTags. Remove all instances should be 3) of the following lines from the function.
list($content, $markers) = GLText::protectJavascript($content);
$content = GLText::unprotectJavaScript($content, $markers);
and for this line:
return GLText::unprotectJavaScript($content, $markers) . $LANG32[32];
replace with:
return $content . $LANG32[32];
One of the Geeklog Core Developers.
In lib-plugins.php look at the function PLG_replaceTags. Remove all instances should be 3) of the following lines from the function.
Text Formatted Code
list($content, $markers) = GLText::protectJavascript($content);
$content = GLText::unprotectJavaScript($content, $markers);
and for this line:
Text Formatted Code
return GLText::unprotectJavaScript($content, $markers) . $LANG32[32];
replace with:
Text Formatted Code
return $content . $LANG32[32];
One of the Geeklog Core Developers.
15
18
Quote
All times are EST. The time is now 12:50 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content