Bug: Substitution In Verbatim Preview
Verbatim blocks have macros and urls substituted in the preview view after an edit. The macros and urls are not substituted in a regular view.
Test case
Edit this page, preview it and note how macros and urls are substituted in the preview in the sample block of verbatim text below, then save the preview and note that the macros and urls are not substituted in the regular view.
<head>
<title> %WIKITOOLNAME% . %WEB% . %TOPIC% %TMPL:P{"titleaction"}%</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="robots" content="noindex" /> %HTTP_EQUIV_ON_VIEW%
<base href="%SCRIPTURL%/view%SCRIPTSUFFIX%/%WEB%/%TOPIC%" />
<link rel="stylesheet" type="text/css" href="http://localhost/apache/twiki/data/twiki.css">
</head>
Is this bug that hard to fix?
Environment
| TWiki version: |
TWiki.org latest as of 24 April, 2002 |
| TWiki plugins: |
n/a |
| Server OS: |
n/a |
| Web server: |
n/a |
| Perl version: |
n/a |
| Client OS: |
Windows 2000 Professional SP 1 + Hotfixes |
| Web Browser: |
IE 6.0 |
--
DavidLeBlanc - 24 Apr 2002
Follow up
Judging by the complexity of the code to fix the other Verbatim bugs, this is not going to be that trivial to fix. All patches will of course be very welcome
--
RichardDonkin - 04 May 2002
I think this is just a matter of duplicating code used in view.pl into preview.pl - it should do the same thing in both places imo and view.pl has it right already.
--
DavidLeBlanc - 04 May 2002
The problem is due to a rendering call, followed by a commonTags substituion - see the following code fragment:
$ptext = &TWiki::handleCommonTags( $ptext, $topic );
$ptext = &TWiki::getRenderedVersion( $ptext );
# do not allow click on link before save:
$ptext =~ s@(href=".*?")@href="%SCRIPTURLPATH%/oops%SCRIPTSUFFIX%/%WEB%/%TOPIC%\?template=oopspreview"@goi;
$ptext = &TWiki::handleCommonTags( $ptext, $topic );
getRenderedVersion changes <verbatim> to <pre> and then the
handleCommonTags doesn't see the verbatim tag and hence does a substitution. Simplest thing might be to move the href substitution to
getRenderedVersion with a parameter to indicate it is to be used. That way the verbatim problem could be fixed and also the href oops substitution wouldn't change the links in the verbatim section.
--
JohnTalintyre - 25 May 2002
Fix record
Actually added call to remove the verbatim text before common tag handling and rendering, then put it back.
--
JohnTalintyre - 25 May 2002