From c834d84db0c216997368d80e47cf0bba0a2f9e68 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 14 Nov 2004 14:28:29 +0100 Subject: [PATCH] Checking PID language codes for ISO 639 compliance --- HISTORY | 4 +++- i18n.c | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/HISTORY b/HISTORY index e640fac4..4190166b 100644 --- a/HISTORY +++ b/HISTORY @@ -3117,7 +3117,7 @@ Video Disk Recorder Revision History learned inside the menu to avoid overwriting the date/time in the 'classic' skin (thanks to Oliver Endriss for reporting this one). -2004-11-07: Version 1.3.16 +2004-11-14: Version 1.3.16 - Fixed cChannel::SetName() in case only the ShortName or Provider has changed (thanks to Sascha Volkenandt for reporting this one). @@ -3132,3 +3132,5 @@ Video Disk Recorder Revision History - Fixed a short glitch when starting a recording on the primary device while in replay or transfer mode (thanks to Marco Schlüßler). - Added missing initialization of cEvent::seen. +- Checking PID language codes for ISO 639 compliance to avoid problems with + funny characters. Invalid language codes will be stored as "???". diff --git a/i18n.c b/i18n.c index 2f096bb2..75756041 100644 --- a/i18n.c +++ b/i18n.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: i18n.c 1.162 2004/11/06 10:26:52 kls Exp $ + * $Id: i18n.c 1.163 2004/11/14 14:28:29 kls Exp $ * * Translations provided by: * @@ -75,6 +75,7 @@ */ #include "i18n.h" +#include #include "config.h" #include "tools.h" @@ -5222,6 +5223,12 @@ int I18nLanguageIndex(const char *Code) const char *I18nNormalizeLanguageCode(const char *Code) { + if (Code[0] && !isalnum(Code[0]) || Code[1] && !isalnum(Code[1]) || Code[2] && !isalnum(Code[2])) { + // ISO 639 language codes are defined as alphabetical characters, but digits are apparently + // also used, for instance for "2ch" + //dsyslog("invalid language code: '%s'", Code); + return "???"; + } int n = I18nLanguageIndex(Code); return n >= 0 ? I18nLanguageCode(n) : Code; }