Problem with interpretation of images

Hi,

I face a problem with images I put in
/opt/rt4/local/plugins/RTx-MyPlugin/html/NoAuth/img

Some pictures are loaded correctly and some cause errors.

The reason for this is, that the picture-files are interpreted by the
perl-interpreter and if the file contains a <% or <$ or simular things,
that the interpreter is looking for, it throws an error.

What can I do to fix this?

My appache config for rt4 looks like that:

AddDefaultCharset UTF-8

Order allow,deny
Allow from all

SetHandler modperl
PerlResponseHandler Plack::Handler::Apache2
PerlSetVar psgi_app /opt/rt4/sbin/rt-server
use Plack::Handler::Apache2; Plack::Handler::Apache2->preload("/opt/rt4/sbin/rt-server");

Can anybody provide me a hint how I can handle this problem. The only
solution I see so far is recoding all pictures in the hope, that it
doesn’t contain a problematic string afterwards. :frowning:

greetings,
Alexander

I face a problem with images I put in
/opt/rt4/local/plugins/RTx-MyPlugin/html/NoAuth/img

Some pictures are loaded correctly and some cause errors.

The reason for this is, that the picture-files are interpreted by the
perl-interpreter and if the file contains a <% or <$ or simular things,
that the interpreter is looking for, it throws an error.

What can I do to fix this?

Use an autohandler to serve the images statically instead of through
Mason automatically. See how core RT does this in
share/html/NoAuth/images/autohandler

Thomas

I face a problem with images I put in
/opt/rt4/local/plugins/RTx-MyPlugin/html/NoAuth/img

Some pictures are loaded correctly and some cause errors.

The reason for this is, that the picture-files are interpreted by the
perl-interpreter and if the file contains a <% or <$ or simular things,
that the interpreter is looking for, it throws an error.

What can I do to fix this?

Use an autohandler to serve the images statically instead of through
Mason automatically. See how core RT does this in
share/html/NoAuth/images/autohandler

I would recommend to put them into
html/NoAuth/images/my-ext-prefix-xxxx.image. This way they served by
RT’s autohandler and you don’t need to duplicate it. I don’t remember
if you can use subdirectory or not, try
html/NoAuth/images/my-extnsion/xxx.image.

Thomas

Best regards, Ruslan.

I face a problem with images I put in
/opt/rt4/local/plugins/RTx-MyPlugin/html/NoAuth/img

Some pictures are loaded correctly and some cause errors.

The reason for this is, that the picture-files are interpreted by the
perl-interpreter and if the file contains a <% or <$ or simular things,
that the interpreter is looking for, it throws an error.

What can I do to fix this?

Use an autohandler to serve the images statically instead of through
Mason automatically. See how core RT does this in
share/html/NoAuth/images/autohandler

Well, thanks for the idea. But autohandler doesn’t work at all. Neither
in share/html/NoAuth/images nor anywhere else. It’s beeing ignored.
I copied the picture, see attachment, into share/html/NoAuth/images and
got the Mason-compiling error

error: ‘<&’ without matching ‘&>’
at /opt/rt4/share/html/NoAuth/images/brushed-steel.jpg line 71.

How can I make it work?

Well, thanks for the idea. But autohandler doesn’t work at all. Neither
in share/html/NoAuth/images nor anywhere else. It’s beeing ignored.
I copied the picture, see attachment, into share/html/NoAuth/images and
got the Mason-compiling error

It doesn’t work because Mason attempts to compile the image as a Mason
file before it sees the autohandler. I think the only solution is to
take all the images outside the Mason environment. Would adding a
Alias /NoAuth/images/ /opt/rt4/share/html/NoAuth/images/ before the
DocumentRoot line do that? I’m not really good with Apache
configuration.

http://www.linkedin.com/in/paultomblin
http://careers.stackoverflow.com/ptomblin

Well, thanks for the idea. But autohandler doesn’t work at all. Neither
in share/html/NoAuth/images nor anywhere else. It’s beeing ignored.
I copied the picture, see attachment, into share/html/NoAuth/images and
got the Mason-compiling error

It doesn’t work because Mason attempts to compile the image as a Mason
file before it sees the autohandler. I think the only solution is to
take all the images outside the Mason environment. Would adding a
Alias /NoAuth/images/ /opt/rt4/share/html/NoAuth/images/ before the
DocumentRoot line do that? I’m not really good with Apache
configuration.

Well, sure this will work, but on the other hand you lose the ability to
use an image within a plugin. For example I have the plugin MyPlugin and
want to use an image for the plugin. So I will not put it in the general
share/html/NoAuth/images because this makes a mess when exporting this
plugin or updating RT since the plugin is not a encapsulated anymore and
the image would be outside of the “protected” area of the plugin.

What is needed is a smart way to determine whether a requested file is
an image and so let it pass without processing or whether it’s another
type of file - so process it.

Is there such a way?
Or is there a way to do this with apache? Maybe with the rewrite mod?
Or how can I configure Mason so that the autohandler will be touched
first, and any other file second? I don’t have any experience with
Mason. :frowning:

Thanks for your thoughts and help.
Alex

Use an autohandler to serve the images statically instead of through
Mason automatically. See how core RT does this in
share/html/NoAuth/images/autohandler

Well, thanks for the idea. But autohandler doesn’t work at all. Neither
in share/html/NoAuth/images nor anywhere else. It’s beeing ignored.
I copied the picture, see attachment, into share/html/NoAuth/images and
got the Mason-compiling error

Make your plugin’s images directory something that’s not in core RT.
You’re running into an annoying Mason quirk involving autohandlers and
multiple component roots, I believe.

html/NoAuth/RT-Extension-Foo/images/autohandler
html/NoAuth/RT-Extension-Foo/images/brushed-steel.jpg

etc.

Make your plugin’s images directory something that’s not in core RT.
You’re running into an annoying Mason quirk involving autohandlers and
multiple component roots, I believe.

html/NoAuth/RT-Extension-Foo/images/autohandler
html/NoAuth/RT-Extension-Foo/images/brushed-steel.jpg

I’ve encountered the same problem even if I put my image in
/opt/rt4/share/html/NoAuth/images, at least with the standalone
server.

http://www.linkedin.com/in/paultomblin
http://careers.stackoverflow.com/ptomblin

Make your plugin’s images directory something that’s not in core RT.
You’re running into an annoying Mason quirk involving autohandlers and
multiple component roots, I believe.

html/NoAuth/RT-Extension-Foo/images/autohandler
html/NoAuth/RT-Extension-Foo/images/brushed-steel.jpg

I’ve encountered the same problem even if I put my image in
/opt/rt4/share/html/NoAuth/images, at least with the standalone
server.

Try the dhandler approach. Serve images out of a subdirectory from
virtual paths. See how we do this with the CKEditor source.

I’ve encountered the same problem even if I put my image in
/opt/rt4/share/html/NoAuth/images, at least with the standalone
server.

Try the dhandler approach. Serve images out of a subdirectory from
virtual paths. See how we do this with the CKEditor source.

So, here is what I did to solve this problem. Thanks for this
suggestion. Now I do understand how this thing with the dhandler works.

I moved! my images into a subfolder called hiddensource. The image-file
may not exist in the original folder anymore!
So /NoAuth/plugin/images/sample.jpg is now located in
/NoAuth/plugin/images/hiddensource/sample.jpg.

Then I created the dhandler file in /NoAuth/plugin/images/. Its content
is
<%INIT>
use File::Basename;
my $arg = $m->dhandler_arg;
my $file = dirname($m->current_comp->source_file) . ‘/hiddensource/’.
$arg;
RT::Interface::Web->SendStaticFile( File => $file );

$m->abort;
</%INIT>

To make sure that the files in hiddensource are not accessed via the
browser from outside, because this might cause a security flaw, I also
had to adjust my Apache Server.
<LocationMatch /NoAuth/.*/?hiddensource/>
Order deny,allow
Deny from all

This can be done in a .htaccess-file in the hiddensource subfolder or in
the main config where you configure apache for your RT.

So my sample.jpg will be accessible via /NoAuth/plugin/images/sample.jpg
and will not be interpreted by Mason. But nobody can access it
via /NoAuth/plugin/images/hiddensource/sample.jpg

I hope this will help somebody else. Thanks to everybody for the
support. :slight_smile:

Alex