> What is the best method of encoding the html.  It
> seems that the problem is double quotes but I'd rather
> have a more robust solution than just handeling the
> quotes.
>
> any suggestions?

(this may not be the 'best' method, but...)

Try:

# warning: untested!

    # an anonymous subref that returns the numeric value of a charcter
    # as %value;
    # i.e.: '"' becomes %34;

my $sub_replace = sub {

    my $value = ord(shift);
    return("%$value;");
    }

    # replace all non-alphanumeric characters with value returned from above

my $input =~ s/([^A-Z0-9])/&$sub_replace($1)/ige;

...
print("<input type=\"hidden\" name=\"hidden\" value=\"$input\">");

----cut----

on your decoding side:

    # grab %(\d+); and replace with actual
    # character by using chr()

my $input =~ s/%(\d+)\;/chr($1)/ge;


Note: it's very important you use the /e modifier.

You can do it many ways, but this should be succintly easy and offer you the
range of coverage you desire.  I haven't tested those subops as I wrote
them, but I'm sure there's no real glaring errors.

!c (dolljunkie)


Attachment: smime.p7s
Description: application/pkcs7-signature

Reply via email to