root2abs()url2abs(URL)changePassword()encryptPassword(PASSWD)stripBadHtml(STRING)approveTag(TAG)fixparam(DATA)fixurl(DATA)fudgeurl(DATA)chopEntity(STRING)addDomainTags(HTML)xmlencode_plain(TEXT)xmlencode(TEXT)xmldecode(TEXT)
Slash::MODULE - SHORT DESCRIPTION for Slash
use Slash::Utility;
# do not use this module directly
LONG DESCRIPTION.
root2abs()Convert rootdir to its absolute equivalent. By default, rootdir is
protocol-inspecific (such as ``//www.example.com'') and for redirects needs
to be converted to its absolute form. There is an absolutedir var, but
it is protocol-specific, and we want to inherit the protocol. So if
$ENV{HTTPS} is true, we use HTTPS, else we use HTTP.
url2abs(URL)Take URL and make it absolute. It takes a URL,
and adds rootdir to the beginning if necessary, and
adds the protocol to the beginning if necessary, and
then uses URI->new_abs() to get the correct string.
Converts dates from the database; takes an arrayref of rows.
This example would take the 1th element of each arrayref in $data, format it,
and put the result in the 2th element.
formatDate($data, 1, 2);
This example would take the ``foo'' key of each hashref in $data, format it,
and put the result in the ``bar'' key.
formatDate($data, 'foo', 'bar');
The timeCalc function does the formatting.
timeCalc function.
Format time strings using user's format preference.
changePassword()Return new random 8-character password composed of 0..9, A..Z, a..z (but not including possibly hard-to-read characters [0O1Iil]).
encryptPassword(PASSWD)Encrypts given password. Currently uses MD5, but could change in the future, so do not depend on implementation.
Private function. Fixes up a string based on what the mode is. This
function is no longer exported, use the strip_* functions instead.
[ Should this be somewhat templatized, so they can customize the little HTML bits? Same goes with related functions. -- pudge ]
stripBadHtml is called first).
stripBadHtml.
breakHtml).
Wrapper for stripByMode. strip_mode simply calls stripByMode
and has the same arguments, but strip_mode will only allow modes
with values greater than 0, that is, the user-supplied modes. strip_mode
is only meant to be used for processing user-supplied modes, to prevent
the user from accessing other mode types. For using specific modes instead
of user-supplied modes, use the function with that mode's name.
See stripByMode for details.
stripBadHtml(STRING)Private function. Strips out ``bad'' HTML by removing unbalanced HTML
tags and sending balanced tags through approveTag. The ``unbalanced''
checker is primitive; no ``<'' or ``>'' tags will are allowed inside
tag attributes (such as <A NAME=``>''>), that breaks the tag.
Also, whitespace is inserted between adjacent tags, so ``<BR><BR>''
becomes ``<BR> <BR>''.
approveTag function.
Private function. Break up long words in some text. Will ignore the
contents of HTML tags. Called from stripByMode functions.
Take a relative URL and fix it to some predefined set.
I don't really like this function much, it should be played with.
approveTag(TAG)Private function. Checks to see if HTML tag is OK, and adjusts it as necessary.
fudgeurl.
fixparam(DATA)Prepares data to be a parameter in a URL. Such as:
my $url = 'http://example.com/foo.pl?bar=' . fixparam($data);
fixurl(DATA)Prepares data to be a URL or in part of a URL. Such as:
my $url = 'http://example.com/~' . fixurl($data) . '/';
fudgeurl(DATA)Prepares data to be a URL. Such as:
my $url = fixparam($someurl);
chopEntity(STRING)Chops a string to a specified length, without splitting in the middle of an HTML entity or HTML tag (so we will err on the short side).
Balances HTML tags; if tags are not closed, close them; if they are not open, remove close tags; if they are in the wrong order, reorder them (order of open tags determines order of close tags).
addDomainTags(HTML)To be called only after balanceTags, or results are not guaranteed.
Munges HTML </a> tags into </a foo.com> tags, where
``foo.com'' is the domain name of the link found in the opening <a>
tag. Note that this is not proper HTML, and that dispComment knows
how properly to convert it back to proper HTML.
xmlencode_plain(TEXT)Same as xmlencode(TEXT), but does not encode for use in HTML. This is currently ONLY for use for <link> elements.
xmlencode(TEXT)Encodes / escapes a string for putting into XML. The text goes through three phases: we first convert all ``&'' that are not part of an entity to ``&''; then we convert all ``&'', ``<'', and ``>'' to their entities. Then all characters that are not printable ASCII characters (\040 to \176) are converted to their numeric entities (such as ``À'').
Note that this is basically encoding a string into valid
HTML, then escaping it for XML. When run through regular
XML unescaping, a valid HTML string should remain
(that is, the characters will be valid for HTML, while it
may not be syntactically correct). You may use something
like HTML::Entities::decode_entities if you wish to get
the regular text.
xmldecode(TEXT)Decodes / unescapes an XML string. It basically just decodes the five entities used to encode ``<'', ``>'', '``', '''``, and ''&``. ''&`` is only decoded if it is not the start of an entity.
This will decode the named, decimal numeric, or hex numeric versions of the entities.
Note that while xmlencode will make sure the characters
in the string are proper HTML characters, xmldecode will
not take the extra step to get back the original non-HTML
text; we want to leave the text as OK to put directly into
HTML. You may use something like
HTML::Entities::decode_entities if you wish to get
the regular text.
Returns a Spam Armored email address for the user associated with the given UID.
This routine DOES NOT save its results back to the user record. This is the responsibility of the calling routine.
Slash(3), Slash::Utility(3).
$Id: Data.pm,v 1.1.2.30 2001/10/10 16:06:26 pudge Exp $