bad characters in epg.data

Message ID 87egez5p3f.fsf@roche-blanche.net
State New
Headers

Commit Message

Peter Münster Dec. 6, 2015, 7:55 p.m. UTC
  On Wed, Dec 02 2015, Klaus Schmidinger wrote:

>> C S19.2E-133-3-263 SVM - GR\326D
>> 
>> Would it be possible/easy to patch vdr to filter out such errors?
>> What is the right function to look at?
>
> Take a look at StripControlCharacters() or cEvent::FixEpgBugs() in epg.c.

It seems, that these functions only take care of the title and the
description, but not the channel name.

Finally, I've patched vdr like this:

--8<---------------cut here---------------start------------->8---
--8<---------------cut here---------------end--------------->8---

It seems to work.
Would it be possible to integrate this patch into vdr?
  

Comments

Klaus Schmidinger Dec. 7, 2015, 4:21 p.m. UTC | #1
> On 06 Dec 2015, at 20:55, Peter Münster <pmlists@free.fr> wrote:
> 
> On Wed, Dec 02 2015, Klaus Schmidinger wrote:
> 
>>> C S19.2E-133-3-263 SVM - GR\326D
>>> 
>>> Would it be possible/easy to patch vdr to filter out such errors?
>>> What is the right function to look at?
>> 
>> Take a look at StripControlCharacters() or cEvent::FixEpgBugs() in epg.c.
> 
> It seems, that these functions only take care of the title and the
> description, but not the channel name.

Sorry, I missed that.

> Finally, I've patched vdr like this:
> 
> --8<---------------cut here---------------start------------->8---
> --- epg.c~      2013-12-28 12:33:08.000000000 +0100
> +++ epg.c       2015-12-06 15:54:58.312233837 +0100
> @@ -1064,11 +1064,32 @@
>         }
> }
> 
> +static char *StripFunny8bitCharacters(const char *src)
> +{
> +    static char dest[100];
> +    strn0cpy(dest, src, 100);
> +    char *s = dest;
> +    int len = strlen(s);
> +    while (len > 0) {
> +        int l = Utf8CharLen(s);
> +        uchar *p = (uchar *)s;
> +        if (l == 1 && *p > 0x7F) {  // this is not utf-8
> +            memmove(s, p + 1, len); // we also copy the terminating 0!
> +            len--;
> +            l = 0;
> +        }
> +        s += l;
> +        len -= l;
> +    }
> +    return dest;
> +}
> +
> void cSchedule::Dump(FILE *f, const char *Prefix, eDumpMode DumpMode, time_t AtTime) const
> {
>   cChannel *channel = Channels.GetByChannelID(channelID, true);
>   if (channel) {
> -     fprintf(f, "%sC %s %s\n", Prefix, *channel->GetChannelID().ToString(), channel->Name());
> +     fprintf(f, "%sC %s %s\n", Prefix, *channel->GetChannelID().ToString(),
> +             StripFunny8bitCharacters(channel->Name()));
>      const cEvent *p;
>      switch (DumpMode) {
>        case dmAll: {
> --8<---------------cut here---------------end--------------->8---
> 
> It seems to work.
> Would it be possible to integrate this patch into vdr?

Well, first we should investigate why this isn’t set correctly in libsi/si.c.
That’s the place where such fixes should actually be done.
I’ll look into this once I have my VDR development environment up and running at
my new place…

Klaus
  

Patch

--- epg.c~      2013-12-28 12:33:08.000000000 +0100
+++ epg.c       2015-12-06 15:54:58.312233837 +0100
@@ -1064,11 +1064,32 @@ 
         }
 }
 
+static char *StripFunny8bitCharacters(const char *src)
+{
+    static char dest[100];
+    strn0cpy(dest, src, 100);
+    char *s = dest;
+    int len = strlen(s);
+    while (len > 0) {
+        int l = Utf8CharLen(s);
+        uchar *p = (uchar *)s;
+        if (l == 1 && *p > 0x7F) {  // this is not utf-8
+            memmove(s, p + 1, len); // we also copy the terminating 0!
+            len--;
+            l = 0;
+        }
+        s += l;
+        len -= l;
+    }
+    return dest;
+}
+
 void cSchedule::Dump(FILE *f, const char *Prefix, eDumpMode DumpMode, time_t AtTime) const
 {
   cChannel *channel = Channels.GetByChannelID(channelID, true);
   if (channel) {
-     fprintf(f, "%sC %s %s\n", Prefix, *channel->GetChannelID().ToString(), channel->Name());
+     fprintf(f, "%sC %s %s\n", Prefix, *channel->GetChannelID().ToString(),
+             StripFunny8bitCharacters(channel->Name()));
      const cEvent *p;
      switch (DumpMode) {
        case dmAll: {