01482: non-existent page in target field

Summary: non-existent page in target field
Created: 2022-09-09 09:21
Status: Open
Category: Bug
From: SteP
Priority: 1
Version: 2.3.11

Description: While viewing (not editing!) file Gallery.TopBar with a text editor, I noticed this field: targets=Gallery.Gallery,Gallery.Name.

Issue: Gallery.Name is non-existent. My guess is that PmWiki tried to add the link template variable [[ {=$Name} ]] to the list of page targets, which resulted in the bogus target Gallery.Name.

Gallery.TopBars contents:
(:pagelist fmt=Gallery.TopBar#menu-entry:)
(:if false:)
(:template first:)
* %list menu-list %item menu-item %apply=link menu-link%[[{$Group} | {{$Group}.{$Group}$Titlespaced}]]
* %item menu-item% %apply=link pure-menu-link%[[{=$Name} | {=$Titlespaced}]]
(:template ! first:)
* %item menu-item% %apply=link menu-link%[[{=$Name} | {=$Titlespaced}]]

I found other wiki pages with bogus targets to different link template variables. SteP

Thanks, good catch! Your analysis is correct, when the page is saved, the conditionals are removed and PmWiki tries to parse all links, and a link to [[ {=$Name} ]] would be sanitized to point to Group.Name.

There are 2 ways to prevent this. First is to wrap the template in the escape characters [@...@]:

(:if false:)[@
* %item menu-item% %apply=link menu-link%[[{=$Name} | {=$Titlespaced}]]

The other is in config.php with such a line:

  $SaveAttrPatterns['/\\{=\\$.*?\\}/i'] = ' '; # PITS:01482

I am considering adding this to the core, however it might not prevent all false positives. Let me think about it. --Petko