Welcome to Geeklog Saturday, November 25 2017 @ 04:16 am EST


Status: offline

Stu1879

Forum User
Newbie
Registered: 04/05/2015
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:
PHP 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:
PHP 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?

Status: offline

Stu1879

Forum User
Newbie
Registered: 04/05/2015
Posts: 5
This looks like a bug. Setting 'Disable Autotags' to true fixes the problem. I guess something is going wrong in PLG_replaceTags(), but PHP is not really my thing...

Status: offline

Stu1879

Forum User
Newbie
Registered: 04/05/2015
Posts: 5

Status: offline

Laugh

Site Admin
Admin
Registered: 27/09/2005
Posts: 1240
Thanks for the report. I had notice this issue in Staticpages as well and had not had a chance to investigate it.
One of the Geeklog Core Developers.

Status: offline

Laugh

Site Admin
Admin
Registered: 27/09/2005
Posts: 1240
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.

Status: offline

ivy

Forum User
Full Member
Registered: 25/11/2004
Posts: 290
Location:Tokyo Japan
Autotags does not work in the scrpt tag.

PHP Formatted Code
<script>
[xxxx:xxx]
</script>



Geeklog Japan https://www.geeklog.jp

Status: offline

Laugh

Site Admin
Admin
Registered: 27/09/2005
Posts: 1240
That is something you want then? An autotag within the script tags?
One of the Geeklog Core Developers.

Status: offline

ivy

Forum User
Full Member
Registered: 25/11/2004
Posts: 290
Location:Tokyo Japan
Yes!

I use Google charts API.
I use autotags in the api.


Geeklog Japan https://www.geeklog.jp

Status: offline

Laugh

Site Admin
Admin
Registered: 27/09/2005
Posts: 1240
Where are you entering the script tags and autotag? Article, Staticpage, or template?
One of the Geeklog Core Developers.

Status: offline

ivy

Forum User
Full Member
Registered: 25/11/2004
Posts: 290
Location:Tokyo Japan
Staticpage.

example:

PHP 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

Status: offline

Laugh

Site Admin
Admin
Registered: 27/09/2005
Posts: 1240
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.

PHP Formatted Code

list($content, $markers) = GLText::protectJavascript($content);

$content = GLText::unprotectJavaScript($content, $markers);
 

and for this line:
PHP Formatted Code

return GLText::unprotectJavaScript($content, $markers) . $LANG32[32];
 

replace with:
PHP Formatted Code

return $content . $LANG32[32];
 



One of the Geeklog Core Developers.

Status: offline

ivy

Forum User
Full Member
Registered: 25/11/2004
Posts: 290
Location:Tokyo Japan
Thanks!
It works correctly.
Geeklog Japan https://www.geeklog.jp

All times are EST. The time is now 04:16 am.

  • 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