Entering javascript in HTML editor is problematic

Asked by steveparks

Hi again,

Sorry to keep asking questions, but this is another one that relates to the HTML editor on textareas...

I'm trying to create a block to display an amazon ad. The code amazon give me to cut and paste is:

<script type="text/javascript"><!--
amazon_ad_tag = "news42-21"; amazon_ad_width = "160"; amazon_ad_height = "600"; amazon_ad_link_target = "new"; amazon_ad_price = "retail"; amazon_ad_include = "satire;humour;comedy;politics"; amazon_ad_categories = "abc";//--></script>
<script type="text/javascript" src="http://www.assoc-amazon.co.uk/s/ads.js"></script>

I submit this in a blocks textfield, with the editor in HTML mode, selecting 'Full HTML' as the input type.

The ad doesn't work properly, and when i look at the page source, this is what's displayed:

<script type="text/javascript">&lt;!--
amazon_ad_tag = "news42-21"; amazon_ad_width = "160"; amazon_ad_height = "600"; amazon_ad_link_target = "new"; amazon_ad_price = "retail"; amazon_ad_include = "satire;humour;comedy;politics"; amazon_ad_categories = "abc";//--></script>
<script type="text/javascript" src="http://www.assoc-amazon.co.uk/s/ads.js"></script>

It seems to be still filtering the content somehow.

Is it possible to allow some users (eg the admin) to completely disable the WYSIWYG editor on a textfield if they choose, so they can just select plain text?

Otherwise, what can i do to enable this to be submitted correctly please?

Thanks again for any help
Steve

Question information

Language:
English Edit question
Status:
Solved
For:
ProsePoint Edit question
Assignee:
No assignee Edit question
Solved by:
bengtan
Solved:
Last query:
Last reply:
Revision history for this message
Best bengtan (bengtan) said :
#1

Hi,

The last left-angle bracket on the first line is being converted into &lt;

That's what is corrupting your javascript code (I think that's the only instance of corruption. If I've missed another one, let me know).

In this case, the culprit is not the editor.

ProsePoint/Drupal has an inbuilt html syntax corrector (which is enabled by default) and that is getting confused by your first line of javascript. It thinks you actually wanted to display a left-angle bracket, so it's converted that into correct html syntax for you. A bit too clever, but not clever enough.

To disable the html syntax corrector, go to:

Administer // Site configuration // Input filters, for the row 'Full HTML', click the 'configure' link.

That takes you to the page .../admin/settings/filters/2. On this page, untick the checkbox 'HTML corrector', and click 'Save configuration'. That should fix up your problem.

A couple of thoughts:

If you disable the editor by switching to HTML mode, the editor should no longer interfere in any way (especially after you applied the patch from the other Launchpad question). If you believe otherwise, let me know and I'll investigate.

Disabling the html syntax corrector affects all content (nodes, blocks et. al) that uses the full html filter. This should not be an issue, but I thought you'd like to be aware of it.

Let me know how you go.

Oh, and please keep these questions coming :) The earlier we find out about issues (even just configuration related ones like this), the earlier we can address them.

Revision history for this message
steveparks (steve-parks-redgroup) said :
#2

Thanks again for such a speedy and helpful response.

That's done it.

By the way - one thing to consider. I set up a default input format called 'plain text' that filters all html tags etc, because I don't want user comments to include anything other than text - but that's now also the default for any 'staff' entering content, so they have to remember to change it each time.
Is there a simple way to set a different default input format per role? or even per content type?

You guys are great, I'm now a raving fan!

Steve

Revision history for this message
bengtan (bengtan) said :
#3

> Is there a simple way to set a different default input format per role? or even per content type?

Unfortunately, that's not quite possible in ProsePoint out of the box. However, I'm sure it has been done before in the upstream Drupal CMS, so it should be just a case of evaluating and selecting a solution and then testing. Give me a day or so and let me get back to you on it. Although with it being close to the weekend over here in Australia, you might have to wait until Monday :(

Revision history for this message
bengtan (bengtan) said :
#4

Oh, btw, I just realised the filtered html doesn't allow common html tags like <b> and <strong>. Our mistake. We'll rectify in the next ProsePoint release. In the meantime, you might like to do something about that on your site.

Revision history for this message
steveparks (steve-parks-redgroup) said :
#5

After posting I also had the idea about drupal modules and have been doing some research. Unfortunately the solutions don't seem very up to date...

http://drupal.org/project/default_filter
http://drupal.org/project/preferred_format
http://drupal.org/project/filter_default

... but may offer a good starting point. If I get time over the weekend I'll experiment. Otherwise, speak to you monday!

Have a great one
Steve

Revision history for this message
bengtan (bengtan) said :
#6

Hi,

Had a look at those modules, and experimented with http://drupal.org/project/preferred_format and http://drupal.org/project/filter_default. Didn't try http://drupal.org/project/default_filter since that's not available for Drupal 5.x.

In my limited testing, either of http://drupal.org/project/preferred_format and http://drupal.org/project/filter_default works (using the current dev- snapshot as of writing). It just depends on which you prefer.

http://drupal.org/project/filter_default only sets default filters by roles. It is not as flexible, but this also means the site admin has more site-wide control over the default filter for users.

http://drupal.org/project/preferred_format allows each user to set their own default filter, and they can specify different values for different content types and comments. This is much more flexible, but also requires a bit more setup.

It's up to you which one you want to use.

However, these modules can be considered as not part of ProsePoint (not anytime soon, anyway) - despite the fact I'm referring you to them, If you run into issues, we might not be able to support you as well as "official" ProsePoint modules (not that I'm expecting any issues, but I can't be certain).

Finally, it looks like there is a bug relating to input filters for a fresh ProsePoint install. The Full HTML filter should be enabled for the roles administrator and editor, but it isn't. You might want to check that they are on your site.

Revision history for this message
bengtan (bengtan) said :
#7

Grr... a correction:

Didn't try http://drupal.org/project/default_filter since that's not available for Drupal 6.x.