error when string has a ' (quote char)

vindex - July 2, 2009 - 13:01
Project:Automatic Nodetitles
Version:6.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:by design
Description

I create my node title from two custom cck textfields: firstname and
lastname.

When lastname contains a string with an embedded quote (e.g "D'Ascanio")
I get this error:

Parse error: syntax error, unexpected T_STRING in /usr/local/share/drupal/modules/auto_nodetitle/auto_nodetitle.module(220) : eval()'d code on line 4

#1

timtrinidad - July 12, 2009 - 14:26

I had this problem too. Here's what I ended up using (note the " instead of the '):

<?php
return "[field_song_title-raw]";
?>

#2

fago - July 31, 2009 - 12:01
Status:active» by design

That's a dangerous snippet, from the latest (dev) readme:

You can combine php evalution with the token module, because tokens are replaced first.
However be aware to don't use this with any textual values provided by users as this would
open a security hole. If you are in doubt, don't combine tokens with php evaluation.

#3

radman16 - August 10, 2009 - 19:45

So what is the recommended way of avoiding this error when the token field contains punctuation. I have seen this or similar error when the field contains either a quote or a period.

 
 

Drupal is a registered trademark of Dries Buytaert.