Bug: Variables in Square Bracket Links dont work in form fields
see title!
Test case
see "Topic Summary" field below (I hijacked that field for this purpose)
Environment
--
MartinGregory - 02 Apr 2004
Follow up
Question
It appears that ATTACHURL doesn't work properly in a form field.
If you edit this page and copy this:
DynIP.txt
down in the "AssignedQuestionTo" field, you will see that
it appears as an unresolved wiki link instead of a valid
file attachment link... yet the link above remains valid.
(I have put it down there myself and that is what I see... I presume
the person to whom this is assigned will have to re-do that, since
their name will be put into
AssignedTo by the assigner, right!?)
Is that right? Is there some reason why variables
in general can't appear in form fields?
Environment
--
MartinGregory - 23 Mar 2004
Call me an impatient bastard, but pretty please could someone look at this?
--
MartinGregory - 01 Apr 2004
- yep, you can. its not simple though.. its a problem somewhere in the rendering code
and thats horrible. (I'm playing with it, but ug)
- looks like using any VARIABLE in a squarebracket link in a FormField does not work. interesting
I don't know if there is a reason why there is no handleCommonTags before the getRenderedVersion. The patch below makes it work, but I am not sure that it has not been left out for a reason - anyone else care to comment?
If there are no objections, I will commit this - and later change the code so that handleCommonTags gets called in getRenderedVersion.. (or something similar)
Index: lib/TWiki.pm
===================================================================
RCS file: /cvsroot/twiki/twiki/lib/TWiki.pm,v
retrieving revision 1.313
diff --unified=3 -r1.313 TWiki.pm
--- lib/TWiki.pm 30 Mar 2004 08:21:56 -0000 1.313
+++ lib/TWiki.pm 1 Apr 2004 12:00:36 -0000
@@ -3198,6 +3198,7 @@
$metaText .= "| $title:|$value |\n";
}
+ $metaText = handleCommonTags( $metaText, $topic );
$metaText = getRenderedVersion( $metaText, $web );
}
@@ -3804,6 +3805,7 @@
$text = $altText;
}
}
+ $text = handleCommonTags( $text, $web );
$text = getRenderedVersion( $text, $web );
return $text;
}
--
SvenDowideit - 01 Apr 2004
Answer
I think my question is answered: it looks like a bug.
Thanks for your quick response Sven. I might even apply your
patch to my (1 Feb 2003 production version!) of Twiki.pm
and see if it fixes it! (Assuming that it's even similar
enough for the diff to work).
Probably this belongs in a bug report now, rather than a
support question?
--
MartinGregory - 02 Apr 2004
Not sure if this is the right fix. The view script does this rendering:
$tmpl = &TWiki::handleCommonTags( $tmpl, $topic );
if( $viewRaw ) {
$tmpl =~ s/%META{[^}]*}%//go;
} else {
$tmpl = &TWiki::handleMetaTags( $webName, $topic, $tmpl, $meta, ( $rev == $maxrev ) );
}
writeDebugTimes( "view - handleCommonTags for template done" );
$tmpl = &TWiki::getRenderedVersion( $tmpl, "", $meta ); ## better to use meta rendering?
whereas
TWiki::renderFormData() does this:
$text =~ s/%META{\s*"form"\s*}%/&renderFormData( $theWeb, $theTopic, $meta )/ge;
$text =~ s/%META{\s*"formfield"\s*(.*?)}%/&renderFormField( $meta, $1 )/ge;
$text =~ s/%META{\s*"attachments"\s*(.*)}%/&TWiki::Attach::renderMetaData( $theWeb,
$theTopic, $meta, $1, $isTopRev )/ge;
$text =~ s/%META{\s*"moved"\s*}%/&renderMoved( $theWeb, $theTopic, $meta )/ge;
$text =~ s/%META{\s*"parent"\s*(.*)}%/&renderParent( $theWeb, $theTopic, $meta, $1 )/ge;
$text = &TWiki::handleCommonTags( $text, $theTopic );
That is, we have this rendering sequence:
- common tags
- meta tag handling:
- get rendered version (in case of form fields)
- common tags (for all meta tags)
- get rendered version (for whole text including meta data)
It looks like the correct fix is to remove the
getRenderedVersion() call in
TWiki::renderFormData(). It needs to be checked if this does not introduce other issues elsewhere / if other meta data renering like
renderFormField(),
renderMetaData(),
renderMoved(),
renderParent() needs to have the same fix.
Again, this added complexity could be reduced if we
SimplifyInternalMetaDataHandling into one flat stream of data.
This is a bug that should be tracked in
BugReport.
--
PeterThoeny - 02 Apr 2004
It is reported here:
VariableInSquareBracketLinkDoestWorkInFormField
--
MartinGregory - 02 Apr 2004
Fix record
looks like i accidently fixed this when i reduced the number of handleCommonTags and getRenderedVersion that we do in the handleMetaData code (now its down to 6 every view)
its in CVS now
--
SvenDowideit - 21 Apr 2004