glensc / dokuwiki-plugin-pageredirect

Redirects page requests based on content
https://www.dokuwiki.org/plugin:pageredirect
19 stars 19 forks source link

regex is greedy #5

Closed andywebber closed 11 years ago

andywebber commented 11 years ago

It is sometimes useful to leave the old content in a page that is redirected (for posterity, for inclusion in search results, etc).

However, if the page includes any other markup which uses "" notation, the pageredirect plugin fails badly (generates a blank page). The reason is that the regex used to match "REDIRECT>page~~" is greedy; it should be lazy

Test case: page with:

  ~~REDIRECT>anotherpage~~
  ~~CLEARFLOAT~~
  ~~DISCUSSION~~

See "Tips" under https://www.dokuwiki.org/devel:syntax_plugins#patterns

Pattern should perhaps be something like (?:REDIRECT>.+?|^#(?i:redirect) [^\r\n]+), but I haven't tested this.

ssahara commented 11 years ago

Is this issue topic still open? I also suffering from mismatch of "REDIRECT>.+?", which matches other markup that uses "~~". Attempt to match pageid fails due to the greediness of pattern ".+?".

I would like to propose "(REDIRECT>.*?|^#(?i:redirect) [^\n]+)".