|
thanx Steve.
I will look into that. Is there any way to get the IHTMLDOMText from the IHTMLElement interface ???
llp00na
|
|
|
|
|
Thanx for ur valuable advice Steve.
I think i can use IHTMLElement4::getAttributeNode to get IHTMLDOMAttribute2. nodeType of this interface will allow me to specify the type of the node ie. text node, element node.
but i am not sure quite sue what do they mean by text node and element node !!!
do u have any idea ?
llp00na
-- modified at 11:28 Thursday 2nd March, 2006
|
|
|
|
|
I don't believe you can get a IHTMLDOMTextNode from a IHTMLElement interface because the basic philosophy is different - The IHTMLElement family doesn't include text nodes but exposes the text info using the IHTMLElement::get_innerText method. The IHTMLDOMTextNode exposes text nodes W3C style. You can get a IHTMLDOMNode from a IHTMLElement however - By QIing I believe. Can you explain your problem in more detail? Perhaps then I can give some concrete advice.
Steve
|
|
|
|
|
Thanx for you reply and infinite patience;
I am parsing an html DOM tree and trying to extract text with no tags (lets call it: text node or free text).
The way i approached this problem is as follows:
1-I have implemented an internet explorer web browser (the usual way, by adding a microsoft web browser control into my MFC application).
2-I am retrieving the IHTMLDocument2 interface from the IWebBrowser2 interface.
3-I have then retrieved the body element from the IHTMLDocument2.
4-I am looping through the html elements of the body and assessing whether a specific element is a text node (free text) or not.
What do you think ?
Thank you again steve
llp00na
|
|
|
|
|
I'm not quite sure what you mean - all text will be inside some tag. Perhaps it will be easier if you describe the desired effect by example. ie.
<html>
<head>
<title>The title</title>
</head>
<body>
Some text.
<p>Some text.</p>
<p><b>S</b>ome <b>t</b>ext.</p>
<span>Some <b>text</b></span>
</body>
</html>
What text should be returned in this case? Or perhaps you have a better example.
Steve
|
|
|
|
|
thanx steve;
in your example, i should return the following:
<html>
<head>
<title>The title</title>
</head>
<body>
Some text. -------->> Should return this
<p>Some text.</p>
<p>
<b>S</b>
ome ------------->> Should return this
<b>t</b>
ext. ------------>> Should return this
</p>
<span>
Some ----------->> Should return this
<b>text</b>
</span>
</body>
</html>
Hopefully its much clearer now.
llp00na
-- modified at 10:12 Friday 3rd March, 2006
|
|
|
|
|
I'm still a bit confused here. In the example:
<html>
<head>
<title>The title</title>
</head>
<body>
Some text. -------->> Should return this
<p>Some text.</p> <<----- STEVE: We don't return this?
<p>
<b>S</b>
ome ------------->> Should return this <<----- STEVE: But we do return this?
<b>t</b>
ext. ------------>> Should return this
</p>
<span>
Some ----------->> Should return this
<b>text</b>
</span>
</body>
</html>
Can you explain the bits marked with "STEVE"?
For this bit:
<p>Some text.</p> <<----- STEVE: We don't return this?
If I added the modified it as follows:
<p><b>new bit</b> Some text.</p> <<----- STEVE: We don't return this?
What difference would it make?
Steve
|
|
|
|
|
Thank you steve,
quoted:
"If I added the modified it as follows:
<p><b>new bit</b> Some text.</p> <<----- STEVE: We don't return this?"
In this case:
<P>
<b> new bit </b>
Some text . ------------->> should return this
</p>
The text I want to return is the one which does not have an explicit tag
in your example:
<P>
<b> new bit </b> ----> represents the first child of the element P
Some text . ----> represents the second child of the element P
</p>
As you can see, child one and child two are siblings right? and they are both children of element/node <P>.
Now, the first child "new bit" has got an explicit tag (being <b>), however the second child "Some text." does not have an explicit tag.
As a general assumption, let us consider X as an element/node of a DOM tree. If X has got MORE than one child, then return all textual children with no explicit tags.
I hope I made the problem understandable and I am sorry for my inaccurate explanations.
llp00na
-- modified at 11:41 Saturday 4th March, 2006
|
|
|
|
|
Ok, what about this case:
-------------------------
<html>
<head>
<title>The title</title>
</head>
<body>
Some text.
<p>Here is <b><i>s<i>ome</b> text.</p> <--- Do we return the text "ome"?
<p>
<b>S</b>
ome
<b>t</b>
ext.
</p>
<span>
Some
<b>text</b>
</span>
</body>
</html>
Steve
-- modified at 21:01 Saturday 4th March, 2006
|
|
|
|
|
Thanx steve:
<body>
Some text.
<p>
Here is -----> should return this
<b>
<i>s<i>
ome ------> should return this
</b>
text. -------> should return this as well
</p> <--- Do we return the text "ome"?
<p>
<b>S</b>
ome -----> return this
<b>t</b>
ext. ----> return this
</p>
<span>
Some ---> return this
<b>text</b>
</span>
</body>
llp00na
|
|
|
|
|
Here's some code which doesn't do what you want, but contains all the elements you need. You should be able to alter it to suit your needs. It uses straight COM without any smart pointers. Normally I'd use ATL smart pointers but I thought this way it will work "out of the box", you can alter it use your favorite smart pointers. The code will be considerably smaller if you alter it to use some kind of smart pointer. Here goes:
-------------
void CMFCWebBrowserDlg::OnButton1()
{
IDispatch *pDisp = m_Browser.GetDocument();
if ( pDisp != NULL )
{
IHTMLDocument2 *pDoc2;
HRESULT hr = pDisp->QueryInterface(&pDoc2);
if ( SUCCEEDED(hr) )
{
ASSERT(pDoc2);
IHTMLElement *pBodyElement;
hr = pDoc2->get_body(&pBodyElement);
if ( SUCCEEDED(hr) && pBodyElement )
{
IHTMLDOMNode *pDOMNode;
hr = pBodyElement->QueryInterface(&pDOMNode);
if ( SUCCEEDED(hr) )
{
ASSERT(pDOMNode);
IDispatch *pChildrenDisp;
hr = pDOMNode->get_childNodes(&pChildrenDisp);
if ( SUCCEEDED(hr) )
{
ASSERT(pChildrenDisp);
IHTMLDOMChildrenCollection *pChildrenCollection;
hr = pChildrenDisp->QueryInterface(&pChildrenCollection);
if ( SUCCEEDED(hr) )
{
ASSERT(pChildrenCollection);
long NumItems;
if ( SUCCEEDED(pChildrenCollection->get_length(&NumItems)) )
{
for ( long i=0; i<NumItems; ++i )
{
IDispatch *pItemDisp;
hr = pChildrenCollection->item(i, &pItemDisp);
if ( SUCCEEDED(hr) && pItemDisp!=NULL )
{
// Is it a text node?
IHTMLDOMTextNode *pTextNode;
hr = pItemDisp->QueryInterface(&pTextNode);
if ( SUCCEEDED(hr) )
{
// It's a text node so get the text.
BSTR bstrText;
hr = pTextNode->get_data(&bstrText);
if ( SUCCEEDED(hr) )
{
MessageBoxW(m_hWnd, bstrText, L"Text node", MB_OK);
SysFreeString(bstrText);
}
}
else
{
// It's not a text node.
IHTMLElement *pElem;
hr = pItemDisp->QueryInterface(&pElem);
if ( SUCCEEDED(hr) )
{
ASSERT(pElem);
BSTR bstrOuter;
hr = pElem->get_outerHTML(&bstrOuter);
if ( SUCCEEDED(hr) )
{
MessageBoxW(m_hWnd, bstrOuter, L"Element", MB_OK);
SysFreeString(bstrOuter);
}
pElem->Release();
}
}
pItemDisp->Release();
}
}
}
pChildrenCollection->Release();
}
pChildrenDisp->Release();
}
pDOMNode->Release();
}
pBodyElement->Release();
}
pDoc2->Release();
}
pDisp->Release();
}
}
Steve
|
|
|
|
|
thanx very much steve,
you have been really very helpful
llp00na
|
|
|
|
|
Hi
I have existing website which I have to update. This web uses a cgi mailer. when i try to send email through this page it gives server error. the cgi script is here:
I think that the first 15-20 lines is important.....
START SCRIPT:
#!/usr/bin/perl -wT
BEGIN { $DEBUGGING = 1; }
my $emulate_matts_code= 0;
my $secure = 1;
my $mailprog = '/bin/sendmail -oi -t';
my @referers = qw(fijiamcham.com mail.fijiamcham.com localhost);
my @allow_mail_to = qw(secretariat@fijiamcham.com);
my @recipients = ();
my @valid_ENV = qw(REMOTE_HOST REMOTE_ADDR REMOTE_USER HTTP_USER_AGENT);
my $date_fmt = '%A, %B %d, %Y at %H:%M:%S';
my $style = ''; # '/css/nms.css'; # include your site style sheet here
my $send_confirmation_mail = 0;
my $confirmation_text = <<'END_OF_CONFIRMATION';
From: you@your.com
Subject: form submission
Thankyou for your form submission.
END_OF_CONFIRMATION
#
# USER CONFIGURATION << END >>
# ----------------------------
# (no user serviceable parts beyond here)
# We don't need file uploads or very large POST requests.
# Annoying locution to shut up 'used only once' warning in older perl
$CGI::DISABLE_UPLOADS = $CGI::DISABLE_UPLOADS = 1;
$CGI::POST_MAX = $CGI::POST_MAX = 1000000;
# Merge @allow_mail_to and @recipients into a single list of regexps
push @recipients, map { /\@/ ? "^\Q$_\E\$" : "\@\Q$_\E\$" } @allow_mail_to;
# We need finer control over what gets to the browser and the CGI::Carp
# set_message() is not available everywhere
# This is basically the same as what CGI::Carp does inside but simplified
# for our purposes here.
BEGIN
{
sub fatalsToBrowser
{
my ( $message ) = @_;
if ( $main::DEBUGGING )
{
$message =~ s//>/g;
}
else
{
$message = '';
}
my ( $pack, $file, $line, $sub ) = caller(1);
my ($id ) = $file =~ m%([^/]+)$%;
return undef if $file =~ /^\(eval/;
print "Content-Type: text/html\n\n";
print <<eoerr;
<html>
<title>Error
Application Error
An error has occurred in the program
$message
EOERR
die @_;
};
$SIG{__DIE__} = \&fatalsToBrowser;
}
if ( $emulate_matts_code )
{
$secure = 0; # ;-}
}
my $debug_warnings = '';
# Empty the environment of potentially harmful variables
# This might cause problems if $mail_prog is a shell script
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
$ENV{PATH} = '/bin:/usr/bin';
my %valid_ENV;
@valid_ENV{@valid_ENV} = (1) x @valid_ENV;
# Uncomment the following line (and the Unit Tests section)
# to unit test URL checking functions
#
# unitTest();
my $style_element = $style ?
qq%%
: '';
check_url();
my $date = strftime($date_fmt, localtime);
my (%Config, %Form);
my @Field_Order = parse_form();
check_required();
send_mail();
return_html();
sub check_url {
my $check_referer = check_referer(referer());
error('bad_referer') unless $check_referer;
}
sub check_referer
{
my $check_referer;
my ($referer) = @_;
if ($referer && ($referer =~ m!^https?://([^/]*\@)?([^/]+)!i)) {
my $refHost;
if (defined($1) and (! $secure)) {
$refHost = $1;
chop $refHost;
} else {
$refHost = $2;
}
foreach my $test_ref (@referers) {
if ($refHost =~ m|\Q$test_ref\E$|i) {
$check_referer = 1;
last;
}
elsif ( $secure && $test_ref =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ ) {
if ( my $ref_host = inet_aton($refHost) ) {
$ref_host = unpack "l", $ref_host;
if ( my $test_ref_ip = inet_aton($test_ref) ) {
$test_ref_ip = unpack "l", $test_ref_ip;
if ( $test_ref_ip == $ref_host ) {
$check_referer = 1;
last;
}
}
}
}
}
} else {
$check_referer = $secure ? 0 : 1;
}
return $check_referer;
};
sub parse_form {
my @fields = qw(
recipient
subject
email
realname
redirect
bgcolor
background
link_color
vlink_color
text_color
alink_color
title
sort
print_config
required
env_report
return_link_title
return_link_url
print_blank_fields
missing_fields_redirect
);
@Config{@fields} = (undef) x @fields; # make it undef rather than empty string
my @field_order;
foreach (param()) {
if (exists $Config{$_}) {
my $val = strip_nonprintable(param($_));
next if /redirect$/ and not check_url_valid($val);
$Config{$_} = $val;
} else {
my @vals = map {strip_nonprintable($_)} param($_);
my $key = strip_nonprintable($_);
$Form{$key} = @vals == 1 ? $vals[0] : [@vals];
push @field_order, $key;
}
}
foreach (qw(required env_report print_config)) {
if ($Config{$_}) {
$Config{$_} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{$_} =~ s/(\s+)?\n+(\s+)?//g;
$Config{$_} = [split(/,/, $Config{$_})];
} else {
$Config{$_} = [];
}
}
$Config{env_report} = [ grep { $valid_ENV{$_} } @{$Config{env_report}} ];
return @field_order;
}
sub check_required {
my ($require, @error);
defined $Config{subject} or $Config{subject} = '';
defined $Config{recipient} or $Config{recipient} = '';
if ($Config{subject} =~ /[\n\r]/m ||
$Config{recipient} =~ /[\n\r]/m) {
error('no_recipient');
}
if ($Config{recipient}) {
my @valid;
foreach (split /,/, $Config{recipient}) {
next unless check_email($_);
if (check_recipient($_)) {
push @valid, $_;
}
}
error('no_recipient') unless scalar @valid;
$Config{recipient} = join ',', @valid;
} else {
my @allow = grep {/\@/} @allow_mail_to;
if (scalar @allow > 0 and not $emulate_matts_code) {
$Config{recipient} = $allow[0];
} elsif (%Form) {
error('no_recipient')
} else {
error('bad_referer')
}
}
if ($secure and request_method() ne 'POST') {
error('bad_method');
}
foreach (@{$Config{required}}) {
if ($_ eq 'email' && !check_email($Config{$_})) {
push(@error, $_);
} elsif (defined($Config{$_})) {
push(@error, $_) unless $Config{$_};
} else {
push(@error,$_) unless $Form{$_};
}
}
error('missing_fields', @error) if @error;
}
sub check_recipient {
my ($recip) = @_;
foreach my $r (@recipients) {
if ( ($recip =~ /(?:$r)$/) or $emulate_matts_code and ($recip =~ /$r/i) ) {
return(1);
}
}
warn_bad_email($recip, "script not configured to allow this address");
return(0);
}
sub return_html {
my ($key, $sort_order, $sorted_field);
if ($Config{'redirect'}) {
print redirect $Config{'redirect'};
} else {
print header;
my $title = escape_html( $Config{'title'} || 'Thank You' );
my $recipient = escape_html($Config{'recipient'});
my $attr = body_attributes(); # surely this should be done with CSS
print <<eohtml;
<html>
<title>$title
$style_element
h1.title {
text-align : center;
}
$debug_warnings
$title
Below is what you submitted to $recipient on $date
EOHTML
my @sorted_fields;
if ($Config{'sort'}) {
if ($Config{'sort'} eq 'alphabetic') {
@sorted_fields = sort keys %Form;
} elsif ($Config{'sort'} =~ /^order:.*,.*/) {
$sort_order = $Config{'sort'};
$sort_order =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$sort_order =~ s/(\s+)?\n+(\s+)?//g;
$sort_order =~ s/order://;
@sorted_fields = split(/,/, $sort_order);
} else {
@sorted_fields = @Field_Order;
}
} else {
@sorted_fields = @Field_Order;
}
foreach (@sorted_fields) {
if ($Config{print_blank_fields} || $Form{$_}) {
print '', escape_html($_), ': ',
escape_html($Form{$_}), " \n";
}
}
print qq{ \n};
if ($Config{return_link_url} && $Config{return_link_title}) {
print "\n";
}
print <<end_html_footer;
<hr="" size="1" width="75%">
FormMail
© 2001 London Perl Mongers
END_HTML_FOOTER
}
}
sub send_mail {
my $dashes = '-' x 75;
my $realname = $Config{realname};
if (defined $realname) {
if ($secure) {
# A transform to eliminate some potential problem characters
$realname =~ tr#()\\#{}/#;
$realname =~ s#\s+# #g;
}
$realname = " ($realname)";
} else {
$realname = $Config{realname} = '';
}
my $subject = $Config{subject} || 'WWW Form Submission';
my $email = $Config{email};
unless (defined $email and check_email($email)) {
$email = 'nobody';
}
if ("$Config{recipient}$email$realname$subject" =~ /\r|\n/) {
die 'multiline variable in mail header, unsafe to continue';
}
my $xheader = '';
if ( $secure and defined (my $addr = remote_addr()) ) {
$addr =~ /^([\d\.]+)$/ or die "bad remote addr [$addr]";
$xheader = "X-HTTP-Client: [$1]\n";
}
if ( $send_confirmation_mail ) {
open(CMAIL,"|$mailprog")
|| die "Can't open $mailprog\n";
print CMAIL $xheader, "To: $email$realname\n$confirmation_text";
close CMAIL;
}
open(MAIL,"|$mailprog")
|| die "Can't open $mailprog\n";
print MAIL $xheader, <<eomail;
to: $config{recipient}
from:="" $email$realname
subject:="" $subject
below="" is="" the="" result="" of="" your="" feedback="" form.="" it="" was="" submitted="" by
$config{realname}="" (${\(="" $config{email}||''="" )})="" on="" $date
$dashes
eomail
="" if="" ($config{print_config})="" {
="" foreach="" (@{$config{print_config}})="" print="" mail="" "$_:="" $config{$_}\n\n"="" $config{$_};
="" }
="" }
="" my="" @sorted_keys;
="" ($config{'sort'})="" ($config{'sort'}="" eq="" 'alphabetic')="" @sorted_keys="sort" keys="" %form;
="" }="" elsif="" ^order:.*,.*="" )="" $config{'sort'}="~" s="" (\s+|\n)?,(\s+|\n)?="" ,="" g;
="" (\s+)?\n+(\s+)?="" order:="" ;
="" $config{'sort'});
="" else="" (@sorted_keys)="" ($config{'print_blank_fields'}="" ||="" defined="" $form{$_})="" ",="" (ref="" $form{$_}="" ?="" "@{$form{$_}}"="" :="" $form{$_}),"\n\n";
="" "$dashes\n\n";
="" (@{$config{env_report}})="" $env{$_}\n"="" $env{$_};
="" close="" (mail)="" die="" $!;
}
sub="" check_email="" ($email)="@_;
" return="" 0="" $email="~" ^\s*$="" ;
="" unless="" ($email="~" ^(.+)\@([a-z0-9_\.\-\[\]]+)$="" is)="" warn_bad_email($email,="" "malformed="" email="" address");
="" 0;
="" ($user,="" $host)="($1," $2);
="" ($host="~" \.\.="" "hostname="" $host="" contains="" '..'");
="" ^\.="" starts="" with="" '.'");
="" \.$="" ends="" ($emulate_matts_code="" and="" not="" $secure)="" #="" be="" as="" generous="" possible="" without="" opening="" any="" known="" or="" strongly
="" suspected="" relaying="" holes.
="" ($user="~" ([^a-z0-9_\-\.\#\$\&\'\*\+\="" \="\?\^\`\{\|\}\~\200-\377])/i)" $c="sprintf" '%s="" (ascii="" 0x%.2x)',="" $1,="" unpack('c',$1);
="" "bad="" character="" $c");
="" 1;
="" only="" allow="" reasonable="" addresses.
="" ([^a-z0-9_\-\.\*\+\="])/i)" (length="" $user=""> 100) {
warn_bad_email($email, "username part too long");
return 0;
}
if (length $host > 100) {
warn_bad_email($email, "hostname too long");
return 0;
}
return 1 if $host =~ /^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
return 1 if $host =~ /^[a-z0-9\-\.]+$/i;
warn_bad_email($email, "invalid hostname $host");
return 0;
}
# not reached
return 0;
}
sub warn_bad_email {
my ($email, $whybad) = @_;
$debug_warnings .= <<end if="" $debugging;
<p="">
Warning:
The email address ${\( escape_html($email) )} was rejected
for the following reason: ${\( escape_html($whybad) )}
END
}
# check the validity of a URL.
sub check_url_valid {
my $url = shift;
# allow relative URLs with sane values
return 1 if $url =~ m#^[a-z0-9_\-\.\,\+\/]+$#i;
$url =~ m< ^ (?:ftp|http|https):// [\w\-\.]+ (?:\:\d+)?
(?: / [\w\-.!~*'(|);/?\@&=+\$,%#]* )?
$
>x ? 1 : 0;
}
sub strip_nonprintable {
my $text = shift;
$text=~ tr#\011\012\040-\176\200-\377##dc;
return $text;
}
sub body_attributes {
my %attrs = (bgcolor => 'bgcolor',
background => 'background',
link_color => 'link',
vlink_color => 'vlink',
alink_color => 'alink',
text_color => 'text');
my $attr = '';
foreach (keys %attrs) {
next unless $Config{$_};
if (/color$/) {
next unless $Config{$_} =~ /^(?:#[0-9a-z]{6}|[\w\-]{2,50})$/i;
} elsif ($_ eq 'background') {
next unless check_url_valid($Config{$_});
} else {
die "no check defined for body attribute [$_]";
}
$attr .= qq( $attrs{$_}=") . escape_html($Config{$_}) . '"' if $Config{$_};
}
return $attr;
}
sub error {
my ($error, @error_fields) = @_;
my ($host, $missing_field, $missing_field_list);
my ($title, $heading,$error_body);
if ($error eq 'bad_referer') {
my $referer = referer();
$referer = '' if ! defined( $referer );
my $escaped_referer = escape_html($referer);
if ( $referer =~ m|^https?://([\w\.]+)|i) {
$host = $1;
$title = 'Bad Referrer - Access Denied';
$heading = $title;
$error_body =<<eobody;
<p>
The form attempting to use FormMail resides at $escaped_referer,
which is not allowed to access this program.
If you are attempting to configure FormMail to run with this form,
you need to add the following to \@referers, explained in detail in the
README file.
Add '$host' to your \@referers array.
EOBODY
}
else {
$title = 'Formail';
$heading = $title;
$error_body = 'Badness! ';
}
}
elsif ($error eq 'bad_method') {
my $ref = referer();
if (defined $ref and $ref =~ m#^https?://#) {
$ref = 'at ' . escape_html($ref) . '';
} else {
$ref = 'that you just filled in';
}
$title = 'Error: GET request';
$heading = $title;
$error_body =<<eobody;
<p>
The form $ref fails to specify the POST method, so it would not
be correct for this script to take any action in response to
your request.
If you are attempting to configure this form to run with FormMail,
you need to set the request method to POST in the opening form tag,
like this:
<form action="/cgi-bin/FormMail.pl" method="POST">
EOBODY
} elsif ($error eq 'no_recipient') {
my $recipient = escape_html($Config{recipient});
$title = 'Error: Bad or Missing Recipient';
$heading = $title;
$error_body =<<eobody;
<p>
There was no recipient or an invalid recipient specified in the
data sent to FormMail. Please make sure you have filled in the
recipient form field with an e-mail address that has
been configured in \@recipients. More information on
filling in recipient form fields and variables can be
found in the README file.
The recipient was: [ $recipient ]
EOBODY
}
elsif ( $error eq 'missing_fields' ) {
if ( $Config{'missing_fields_redirect'} ) {
print redirect($Config{'missing_fields_redirect'});
exit;
}
else {
my $missing_field_list = join '',
map { '' . escape_html($_) . "\n" }
@error_fields;
$title = 'Error: Blank Fields';
$heading = $title;
$error_body =<<eobody;
<p>
The following fields were left blank in your submission form:
These fields must be filled in before you can successfully
submit the form.
Please use your back button to return to the form and
try again.
EOBODY
}
}
print header();
print <<end_error_html;
<!doctype html="" public="" "-="" w3c="" dtd="" xhtml="" 1.0="" transitional="" en"
="" "http:="" www.w3.org="" tr="" xhtml1="" xhtml1-transitional.dtd"="">
<title>$title
$style_element
$debug_warnings
$error_body
FormMail
© 2001 London Perl Mongers
|
END_ERROR_HTML
exit;
}
use vars qw(%escape_html_map);
BEGIN
{
%escape_html_map = ( '&' => '&',
'<' => '<',
'>' => '>',
'"' => '"',
"'" => ''',
);
}
sub escape_html {
my $str = shift;
my $chars = join '', keys %escape_html_map;
if (defined($str))
{
$str =~ s/([\Q$chars\E])/$escape_html_map{$1}/g;
}
return $str;
}
# begin Unit Tests
# sub unitTest
# {
# recipientTests();
# refererTests();
# exit(0);
# }
# #
# sub recipientTests()
# {
# recipCheck('you@your.domain', 1, 1);
# recipCheck('you@your.domain', 1, 0);
# recipCheck('some.one.else@your.domain', 1, 1);
# recipCheck('some.one.else@your.domain', 1, 0);
# recipCheck('anyone@localhost', 1, 1);
# recipCheck('anyone@localhost', 1, 0);
# recipCheck('localhost', 0, 1);
# recipCheck('localhost', 0, 0);
# recipCheck('user%elsewhere.com@localhost', 0, 1);
# recipCheck('user%elsewhere.com@localhost', 0, 0);
# #
# recipCheck('YOU@your.domain', 1, 1);
# recipCheck('YOU@your.domain', 0, 0);
# recipCheck('some.one.else@YOUR.domain', 1, 1);
# recipCheck('some.one.else@YOUR.domain', 0, 0);
# recipCheck('anyone@Localhost', 1, 1);
# recipCheck('anyone@Localhost', 0, 0);
# #
# recipCheck('<user@elsewhere.com>your.domain', 0, 0);
# recipCheck('user@elsewhere.com(your.domain', 0, 0);
# }
# #
# sub recipCheck
# {
# my ($recip, $shouldBeGood, $emulate) = @_;
# my $secureMsg;
# #
# $emulate = 0 if ! defined( $emulate );
# #
# if ($emulate)
# {
# $secure = 0;
# $emulate_matts_code = 1;
# $secureMsg = 'insecure';
# }
# else
# {
# $secure = 1;
# $emulate_matts_code = 0;
# $secureMsg = 'secure';
# }
# #
# if ($shouldBeGood)
# {
# if ((! check_email($recip)) or (! check_recipient($recip)))
# {
# warn "$recip should be good ($secureMsg)";
# }
# }
# else
# {
# if (check_email($recip) and check_recipient($recip))
# {
# warn "$recip should be bad ($secureMsg)";
# }
# }
# }
# #
# sub refererTests
# {
# refCheck('xxx.xxx.xxx', 0);
# refCheck('http://dave.org.uk', 1);
# refCheck('http://dave.org.uk/', 1);
# refCheck('http://dave.org.uk/more', 1);
# refCheck('https://dave.org.uk/', 1);
# refCheck(undef, 0, 0);
# refCheck(undef, 1, 1);
# refCheck('https://dave.org.uk@someplace.else.com', 0);
# refCheck('https://dave.org.uk@someplace.else.com', 1, 1);
# refCheck('https://someguy@dave.org.uk', 0, 1);
# refCheck('https://someguy@dave.org.uk', 1, 0);
# refCheck('https://someguy@dave.org.uk/more', 1, 0);
# refCheck('http://209.207.222.64', 1);
# refCheck('http://localhost/', 1);
# }
# #
# sub refCheck
# {
# my ($referer, $shouldBeGood, $emulate) = @_;
# my $secureMsg;
# #
# $emulate = 0 if ! defined( $emulate );
# #
# if ($emulate)
# {
# $secure = 0;
# $secureMsg = 'insecure';
# }
# else
# {
# $secure = 1;
# $secureMsg = 'secure';
# }
# #
# if ($shouldBeGood)
# {
# warn "$referer should be good ($secureMsg)" if ! check_referer($referer);
# }
# else
# {
# warn "$referer should be bad ($secureMsg)" if check_referer($referer);
# }
# }
END SCRIPT.
Deepak Anish
Computer Programmer
Maxumise Fiji Ltd
Suva, Fiji
|
|
|
|
|
|
ITs giving 500 server error...
Deepak Anish
Computer Programmer
Maxumise Fiji Ltd
Suva, Fiji
|
|
|
|
|
Hi, here is my question, any help will be greatly appreciated.
You know how in firefox, when you click on page info and you go to the links section and can view a list of all the links in the current web page. How could I extract all the links from a web page into a list using IWebBrowser2, IHtmlDocument, etc. in C++?
Please help, thanks.
|
|
|
|
|
|
Hi,
Actually in my project i have to ask user to enter data in text field and then show that data in textArea box.
so my problem is a facility to edit that data and remove selected data from textbox once entered...
my question is how can i edit/remove only selected data.
Sushant Mathur
Bangalore,
INDIA.
http://n.domaindlx.com/fun2ssh/HOME.htm
-- modified at 10:16 Wednesday 1st March, 2006
|
|
|
|
|
so you want a user to type some string into a TextBox, then remove all occurrances of that string from the TextArea?
nicko
|
|
|
|
|
|
Hi,
How to implement transactions in Biz logic layer in 3 tier arch.
in asp.net with vb.net or C#.net
pls help on this,
thanks and regards,
Ravi
vaswani_ravi@rediffmail.com
|
|
|
|
|
So.... what's the question?
|
|
|
|
|
Did not got your question brother
|
|
|
|
|
Hi all,
do you know any Javascript or PHP snippet to let the users from a content manager site sort a list of images? what I'd like to do is to put all the images on the page and then let the user sort them. One way could be adding a typical list box with all the image names but I 'd like something more graphic.
Thanks in advance,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
|