[wp-hackers] XHTML Strict Mode
Jamie Talbot
wphackers at jamietalbot.com
Wed Aug 4 10:48:24 UTC 2004
> True; I guess one of the things I was trying to do was to minimize
my
> footprint into the function. Especially since this thing has the
potential
> to mangle user text if not done properly. However, the preg_match()
does not
> include the "/" for singular tags as part of the match, so you'd
have to
> modify the matching pattern, and then even more code to take that
into
> account, which adds up to more risk.
>
Personally, I think this is a better solution, which if coded properly
wouldn't (shouldn't!) be dangerous. But it could easily be altered
later if required, right?
> Actually, that is not necessary. balanceTags() is currently only
called to
> process data on its way into the db. To fix 'more', you just have
to call it
> against the pre-'more' text on its way out of the db (when retrieved
and
> parsed by get_the_content()) ONLY when it's just the pre-'more' text
being
> returned. It'll balance whatever lies before the 'more', but it
doesn't
> affect the actual post content, and won't be called when the whole
post is
> retrieved, so no structure will be broken. I've written it up here:
> http://www.coffee2code.com/archives/2004/08/03/patch-balancing-pre-
more-tags/
Had a look at that. Nifty. :D Of course, this still causes
balancetags to be executed every time a post is displayed. For
multiple posts on one page, lots of viewers, page refreshes etc, this
could add up to quite a lot of work. The post text is unchanging
until someone edits it, so the rebalancing on each occasion is
redundant. I still think a better solution is to call balancetags one
time at post/edit time and save the output to a custom field. This
could easily be achieved using a few filters. This statically created
closing tag list could then be incorporated into the content using
your own get custom field plugin! What do you think?
> Since get_the_content() is already the one responsible for parsing
post
> content and splitting out the 'more', I'd make the change there. In
fact,
> this is a pretty easy fix. The line that explodes <!--more-->:
>
> $content = explode('<!--more-->', $content);
>
> Just make it:
>
> $content = explode('<!--more-->', $content, 2);
>
> The 'limit' arg to explode() was introduced in PHP 4.0.1, and the WP
site says
> we support 4.1, so that should do it. I've made a patch for this
also.
Nice and easy. Was thinking *way* too much about that one!
> Let me know if you were able to "break" balanceTags()!
The only thing I found was the issue you document yourself - that of
multiple inline unbalanced tags being balanced all at the end instead
of individually. However, it would be difficult to secondguess what
the user wanted...
All in all, good stuff! Let me know what you think re the ongoing
more tags saga :D
Jamie
--
http://www.jamietalbot.com
More information about the hackers
mailing list