Allow HTML in description fields?

WebKat
WebKat's picture

Joined: 2002-11-22
Posts: 182
Posted: Mon, 2012-04-09 13:15

I'm running Gallery version 2.3.1 core 1.3.0.1. I was wondering if it was possible either natively or through a plugin or through a (simple for non-programmers like me) hack to allow html (specifically links) in photo and album descriptions? This would be extremely helpful to me. Right now it just shows the html code rather than rendering it.

--
WebKat, Gallery2 holdover extraordinaire.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2012-04-09 13:42

Site admin:Embedded Markup
choose HTML or BB code

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2012-04-09 14:38

Even though you can choose HTML as an option, gallery still filters it.
To fix this edit modules/core/classes/GalleryUtilities.class line ~850

    function htmlSafe($html, $decode=false) {
        list($ret, $isAnon) = GalleryCoreApi::isAnonymousUser();
        if(!$ret && !$isAnon){
            return $html;
        }
        GalleryCoreApi::requireOnce('lib/pear/Safe.php');
        static $parser;
        if (!isset($parser)) {
            $tmp = new HTML_Safe();
            $parser =& $tmp;
        }
        if ($decode) {
            GalleryUtilities::unsanitizeInputValues($html, false);
        }
        $html = $parser->parse($html);
        if ($decode) {
            GalleryUtilities::sanitizeInputValues($html, false);
        }
        return $html;
    }

This will allow any registered user to submit unfiltered html especially helpful if you allow anonymous comments.
If you only want admins to have the option:

    function htmlSafe($html, $decode=false) {
        list ($ret, $isAdmin) = GalleryCoreApi::isUserInSiteAdminGroup();
        if(!$ret && $isAdmin){
            return $html;
        }
        GalleryCoreApi::requireOnce('lib/pear/Safe.php');
        static $parser;
        if (!isset($parser)) {
            $tmp = new HTML_Safe();
            $parser =& $tmp;
        }
        if ($decode) {
            GalleryUtilities::unsanitizeInputValues($html, false);
        }
        $html = $parser->parse($html);
        if ($decode) {
            GalleryUtilities::sanitizeInputValues($html, false);
        }
        return $html;
    }

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
WebKat
WebKat's picture

Joined: 2002-11-22
Posts: 182
Posted: Mon, 2012-04-09 15:48

Thanks, I'll try that out. I don't allow user registration OR comments in my gallery, so that stuff won't matter.

--
WebKat, Gallery2 holdover extraordinaire.

 
WebKat
WebKat's picture

Joined: 2002-11-22
Posts: 182
Posted: Tue, 2012-04-10 03:55

I set it to BBCode because apparently I'd already done BBCode for a bunch of my pieces; also, html mode required that I add <br/> for every line break which is a PITA. However, it isn't rendering the BBCode... see here: http://katherinehowardartist.com/gallery/v/paintings/being_art.jpg.html
In the description below the painting, the link to the prints doesn't work, it just shows the bbcode... why?

--
WebKat, Gallery2 holdover extraordinaire.

 
WebKat
WebKat's picture

Joined: 2002-11-22
Posts: 182
Posted: Fri, 2012-04-20 17:47

Apologies for the bump, I almost never do such a thing, but I'd really like help with this one. I've done the changes and it's set to parse BBcode, but the links aren't working, as in the example in the previous post... help?

--
WebKat, Gallery2 holdover extraordinaire.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2012-04-20 18:36
 
WebKat
WebKat's picture

Joined: 2002-11-22
Posts: 182
Posted: Fri, 2012-04-20 19:43

That worked! thank you! :D:D:D

--
WebKat, Gallery2 holdover extraordinaire.