kaffa / textpattern

Automatically exported from code.google.com/p/textpattern
0 stars 0 forks source link

<txp:comment_x_tags/> don't allow closing without trailing space. #25

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use any txp:comment tag like so: <txp:comment_name_input />. it works in 
4.0.8 and 4.2.0-
rc1.
2. Now, use the same tag without a trailing space: <txp:comment_name_input/>. 
Textpattern 
throws the following warning, and fails to render the specified comment-form 
output: "Textpattern 
Warning: tag does not exist  on line xxx".

As far as I can tell, you can use *any* other Textpattern or TXP plugin tag 
without the trailing 
space-- so far, I've only noticed the comment form tags being affected by this.

This behavior appears in 4.0.8 and 4.2.0-rc1.

Original issue reported on code.google.com by j...@beardedbaby.net on 4 Aug 2009 at 3:32

GoogleCodeExporter commented 8 years ago
Closing a tag without trailing spaces is also okay in XHTML 1.0 Strict:
<meta http-equiv="content-language" content="en-us"/>

Original comment by j...@beardedbaby.net on 4 Aug 2009 at 4:39

GoogleCodeExporter commented 8 years ago

Original comment by r.wetzlmayr on 4 Aug 2009 at 7:40

GoogleCodeExporter commented 8 years ago
fwiw

The trailing space is part of the xhtml 1.0 standard's html compatibility 
guidelines

See Section C2 @ http://www.w3.org/TR/xhtml1/#guidelines

Original comment by tecumseh...@gmail.com on 6 Aug 2009 at 12:35

GoogleCodeExporter commented 8 years ago
> The trailing space is part of the xhtml 1.0 standard's html compatibility 
guidelines

Sure, but txp:tags aren't parsed by browsers that evaluate HTML compatibility-- 
they're parsed by Textpattern.  
Old-school HTML didn't recognize self-closing elements, but Textpattern does.

Thanks for the link, it's good to know.

Original comment by j...@beardedbaby.net on 6 Aug 2009 at 5:09

GoogleCodeExporter commented 8 years ago
John,

It seems that altering line 200 of publish/comment.php to read:

  $Form = preg_replace('#\<txp\:'.$a.'\s?\/\>#', $b, $Form);

fixes it. I've no idea if this has a significant performance penalty -- it 
probably
slows things down a tad -- so there might be a better way.

Original comment by stefdawson on 9 Aug 2009 at 11:17

GoogleCodeExporter commented 8 years ago
I guess it couldn't be any slower than this, @line 1008 of publish.php:

    $f = '@(</?txp:\w+(?:\s+\w+\s*=\s*(?:"(?:[^"]|"")*"|\'(?:[^\']|\'\')*\'|[^\s\'"/>]+))*\s*/?'.chr(62).')@s';

Original comment by j...@beardedbaby.net on 9 Aug 2009 at 9:13

GoogleCodeExporter commented 8 years ago
A cleaner solution would be to make them real tags in taghandlers.php and rely 
on the
tag parser instead of using a simple search and replace which sometimes 
replaces when
it should not (in non-parsed attribute values). $Form is parsed anyway at line 
203.
Performance penalty will be negligible.

There's no direct relation between the length of a regular expression and its 
speed ;)
Keep in mind that regular expressions have to be compiled (which takes time, 
perhaps
more than actually executing it). The search/replace method requires 7 different
regular expressions that are all used only once, while parse() uses only 2 
regexes
repeatedly (regex compilation is cached by PHP).

Original comment by r...@vanmelick.com on 8 Sep 2009 at 9:57