in reply to Re^2: perlre inverse check for several patterns
in thread perlre inverse check for several patterns

no, it is not HTML. It is some interface using some formatting strings like (!!like!!) HTML. But unfotunately the interface crashes if some "<>" strings are included which do not match the allowed formatting strings.

Could you enlighten us as to what exactly this format is and perhaps provide a more representative sample? Also, is it not feasible to fix the crashes in the interface?

  • Comment on Re^3: perlre inverse check for several patterns

Replies are listed 'Best First'.
Re^4: perlre inverse check for several patterns
by averlon (Sexton) on Jun 04, 2023 at 07:14 UTC

    Hi haukex,

    in my private environment I follow some logfiles by File::Tail and report lines of interest to some TELEGRAM Channel via WWW::Telegram::BotAPI. The TELEGRAM API knows some forms of limited formatting of the string to send. One of the formatting options is called "HTML", although there are only 3 or 4 fomatting tags similar to the HTML tags.

    One e.g. is:

    <strong>xxx</strong>

    The example I gave is very much the same as a real logfile line. But if you wish I can give a real example:

    $av_tmp_LINE = "Jun 3 23:20:05 f42252s5 postfix/pickup[204714]: E1E63 +A045C: uid=33 from=<www-data>" $av_tmp_STRING = "Logfile: " . "<strong>" . $av_obj_TMP->{input} . "</ +strong>" . " " . $av_tmp_LINE;

    Now the string $av_tmp_STRING should be sent to the TELEGRAM Channel using "HTML" formatting. But unfotunately inside the string there is the "<www-data>" which looks like a formatting string, but is unsupported.

    This causes the module to abort, although eval is used.

    Messge:

    "Request failed with error 'ERROR: code 400: Bad Request: can't parse +entities: Unsupported start tag "www" at byte offset 53 at /usr/share +/perl5/WWW/Telegram/BotAPI.pm line 224. WWW::Telegram::BotAPI::api_re +quest(undef, undef, HASH(0x55e57ea8da98)) called at ./av_perlre.pl li +ne 268 eval {...} called at ./av_perlre.pl line 266 ', but I'm still +alive! at ./av_perlre.pl line 266."

    Since I am not a very experience programmer, I probably have done something wrong. I have already reported the issue to the module creator.

    My Code:

    $av_std_RETVAL = eval { $av_obj_TGRAM->sendMessage ( { chat_id => $av_loc_tgram_CHATID, text => $av_tmp_STRING, disable_notification => 'false', parse_mode => 'HTML', } ) } or warn "Request failed with error '$@', but I'm still alive!";

    This is according to the docu. The docu says, by using eval the way above, the program will not abort - but it does.

    Regards Kallewirsch

      My fault!

      I ran the test-script in debug mode. The debug stopped and I assumed this aborted the script - but did not!

      The eval works

      Anyhow! I have to find a way to catch the unsupported formatting codes and eliminate them. I guess the regex will do! I will see!

      Regards Kallewirsch