syntax error, unexpected '<', expecting ')'
| Project: | htmLawed |
| Version: | 6.x-2.5 |
| Component: | Code |
| Category: | bug report |
| Priority: | minor |
| Assigned: | alpha2zee |
| Status: | closed |
Jump to:
Like the approach of htmLaw, but I'm running into this error when creating content:
Parse error: syntax error, unexpected '<', expecting ')' in /www/sites/all/modules/htmLawed/htmLawed.module(126) : eval()'d code on line 1
This is because eval('$config = $setting['config'] . ');'); is being sent html:
'safe'=>1, 'elements'=>'a, em, strong, cite, code, ol, ul, li, dl, dt, dd', 'deny_attribute'=>'id, style'
I've looked at cleaning this up a bit using:
eval('$config = array(' . str_replace(array('=', '
', '
'), '', $setting['config']) . ');');
but that's a bad hack. Not sure if there's not a better way to address this, and expect it has to do with other filters I'm using these filters:
URL filter
HTML filter
htmLawed (X)HTML filter/purifier

#1
I am unable to replicate the bug on my computer (Windows XP, PHP 5.2, Drupal 6, htmLawed module 2.5), even if I turn on the 'URL filter' and the 'HTML filter' (the 'HTML filter' is actually not needed when 'htmLawed' is on).
Also, the following PHP script works as expected, suggesting the line of code using 'eval' is probably fine:
<?phperror_reporting(E_ALL | (defined('E_STRICT') ? E_STRICT : 0));
ini_set('display_errors', 1);
$setting['config'] = "'safe'=>1, 'elements'=>'a, em'";
eval('$config = array('. $setting['config']. ');');
print_r($config);
#2
#3
I was seeing the same error and couldn't figure it out for a long time.
However I went back to look at my htmLawed configuration from the input filters settings page (.../admin/settings/filters/1/configure if using this in the Filtered HTML input format) and saw that the Config: text boxes were using my rich text editor (I have fckeditor installed). When I switched to using the plain text editor for these fields instead, I saw that the Config: details had a
<p>and</p>enclosing the actual settings. Deleting these<p>tags for all my htmLawed Default Body/Comment/Other/Teaser settings seems to have fixed these error messages!I have now added the input format settings path in my global exclude list for fckeditor so that it always uses plain text areas.
Hope this makes sense and helps. Let me know if you need more clarification.
#4
Thanks, Piyush. Closing this issue. Users facing a similar issue should ensure that the form-fields for htmLawed settings are not of rich-text type.