[Approved] Mantis 0002874 Multiline channel titles to display correctly in guides / info windows (1 Viewer)

riksmith

Portal Pro
April 18, 2009
1,856
322
Home Country
Netherlands Netherlands
Re: Multiline channel titles to display correctly in guides / info windows

There are indeed new lines in the title. In my opinion this is a bug at the provider's side, you shouldn't have multi line titles, never seen such a thing on any STB. Note that with these events they do not send the description tag!

So my solution stays: remove the new lines and past it all together. If part 1 does not end with a space and part 2 does not start with a space: add one. If both have spaces: keep the formatting (so just paste together).
 

velis

MP Donator
  • Premium Supporter
  • July 16, 2009
    237
    50
    Radovljica
    Home Country
    Slovenia Slovenia
    Re: Multiline channel titles to display correctly in guides / info windows

    I can't really influence the provider, but from technical viewpoint, the provider does not return an invalid XML. Newline in an XML field should not resolve to a newline in data unless a CDATA tag is used.
    This on the other hand is strictly RTVSLO's fault: whenever CDATA tag is used, it is encoded incorrectly ("napovednik" tag only) and thus does not interpret correctly / as intended by any XML parser.

    Your solution is what my patch contains. Provided that I added the relevant code in the correct function, that is :)
    I have also added a line that checks for incorrect CDATA tags which would solve my provider's invalid encoding for the tag, but I'll admit that that particular line is a special case. I don't think it could be harmful though. I sincerely doubt TV providers would have any shows that contained actual <[[CDATA ... ]]> text (not tags) in ANY of the fields.

    The only questionable difference in my solution is for space removal: in the end I always remove double spaces while you propose that only new lines should be treated by a special algorithm. I did that just for the speed and to not have to use too many if statements. A series of replacements which "beautifies" the text, so to speak.
     

    riksmith

    Portal Pro
    April 18, 2009
    1,856
    322
    Home Country
    Netherlands Netherlands
    Re: Multiline channel titles to display correctly in guides / info windows

    I have also added a line that checks for incorrect CDATA tags which would solve my provider's invalid encoding for the tag, but I'll admit that that particular line is a special case. I don't think it could be harmful though. I sincerely doubt TV providers would have any shows that contained actual <[[CDATA ... ]]> text (not tags) in ANY of the fields.

    This is something the devs will have to decide, but you have to be very carefull with programming exceptions to the correct flow. Also you seem the be the first and only person who has reported this (not saying that you are the only one with the problem, but you seem to be the only one bothered enough to report it)

    The only questionable difference in my solution is for space removal: in the end I always remove double spaces while you propose that only new lines should be treated by a special algorithm. I did that just for the speed and to not have to use too many if statements. A series of replacements which "beautifies" the text, so to speak.

    I think the spaces are there for a reason, i would suggest not to remove them. (shouldn't bother anyone, and it is another exception to the normal flow). The double spaces you could try to remove are the double spaces when pasting the lines together.

    If you post an up-to-date patchfile i will move this forum to the patches section. I will also check tonight if i need to file a mantis bug about this.
     

    velis

    MP Donator
  • Premium Supporter
  • July 16, 2009
    237
    50
    Radovljica
    Home Country
    Slovenia Slovenia
    Re: Multiline channel titles to display correctly in guides / info windows

    Thank you.
    I will synchronize SVN tonight and reinsert the relevant lines.
     

    velis

    MP Donator
  • Premium Supporter
  • July 16, 2009
    237
    50
    Radovljica
    Home Country
    Slovenia Slovenia
    Re: Multiline channel titles to display correctly in guides / info windows

    Here's the relevant patch file.

    Jure
     

    Attachments

    • webepg_25679.rar
      30.6 KB

    riksmith

    Portal Pro
    April 18, 2009
    1,856
    322
    Home Country
    Netherlands Netherlands
    Re: Mantis 0002874 Multiline channel titles to display correctly in guides / info win

    Moved to patch section and attached patch to first post.
     

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Mantis 0002874 Multiline channel titles to display correctly in guides / info win

    Why does this patch this:
    Code:
    +      value = value.Replace("\r\n", " ");
    +      value = value.Replace("\n\r", " ");
    +      value = value.Replace("\n", " ");
    +      value = value.Replace("\r", " ");
    +      value = value.Replace("  ", " ");

    instead of:
    Code:
    +      value = value.Replace("\n", " ").Replace("\r", " ").Replace("  ", " ");
     

    velis

    MP Donator
  • Premium Supporter
  • July 16, 2009
    237
    50
    Radovljica
    Home Country
    Slovenia Slovenia
    Re: Mantis 0002874 Multiline channel titles to display correctly in guides / info win

    The first two replaces are there to eliminate excessive space adding. This way I can be sure that the last replace of double spaces to single space will only replace the most obvious double spaces which were possibly added while removing the newlines or that were there to preserve multi line indentation of the text in question.

    As for multiple statements vs. one statement: I find the code more readable that way, especially if one of the replacements were to be added / removed. Diff tools tend to expose the differences much nicer this way than with multiple commands in one single line.
     

    arion_p

    Retired Team Member
  • Premium Supporter
  • February 7, 2007
    3,373
    1,626
    Athens
    Home Country
    Greece Greece
    Re: Mantis 0002874 Multiline channel titles to display correctly in guides / info win

    Please try the attached patch. I have used a RegEx to normalize whitespace (a compiled RegExe can be very fast). Any sequence of whitespace containing at least 2 spaces or any whitespace other than space (newlines, tabs etc) will be replaced by a single space. I have applied this to all single line properties: title, subtitle, genre
     

    Attachments

    • Fix 2874 - Strip newlines in WebEPG titles.patch
      30.7 KB

    velis

    MP Donator
  • Premium Supporter
  • July 16, 2009
    237
    50
    Radovljica
    Home Country
    Slovenia Slovenia
    Re: Mantis 0002874 Multiline channel titles to display correctly in guides / info win

    Just to let you know: I've seen this and will do as suggested, but I won't have time at least until sunday. It's kinda frantic at work right now and I have to work pretty much whole days.

    I have looked at the changes and at first glance I think they will be OK.
    Are you sure you wouldn't give the old bugger the benefit of bad CDATA handling though?
     

    Users who are viewing this thread

    Top Bottom