Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xmltv: handle timezone attached to time with no space padding #707

Closed
wants to merge 1 commit into from

Conversation

dhead666
Copy link
Contributor

@dhead666 dhead666 commented Sep 1, 2015

These changes needed for xmltv downloaded from a VBox Gateway device.

I added a check for alphabetic characters but not actually the parsing of timezone strings.

xmltv example attached
https://www.dropbox.com/s/i7sr7omjfn15rbx/vboxXmltv.xml?dl=0

@perexg
Copy link
Contributor

perexg commented Sep 1, 2015

Timezone strings: Look to https://sourceware.org/bugzilla/show_bug.cgi?id=11620 , comment # 8. It seems like a complex job and using a library makes sense here.

@dhead666
Copy link
Contributor Author

dhead666 commented Sep 1, 2015

Well I didn't intended in this PR to adding timezone string parsing ;)

It doesn't clear to me if the project at the link making available an interface for a timezone string conversion function, it look like not (but I'm a bit inexperienced so I might missed it), maybe it would be better to just offload the parsing of the whole str string to a external library (not sure about ISO 8601 compatibility)?

I'm guessing the other option is to add a dictionary / hash table to parse the strings.

Anyway ATM I'm only interest to get in the no space handling, so if it's appropriate and acceptable I'll just drop the isalpha() tests to avoid confusion.

@perexg
Copy link
Contributor

perexg commented Sep 2, 2015

OK. The isalpha tests are extra, I agree and perhaps this construct is more readable:

diff --git a/src/epggrab/module/xmltv.c b/src/epggrab/module/xmltv.c
index 458bfca..fa1d9b2 100644
--- a/src/epggrab/module/xmltv.c
+++ b/src/epggrab/module/xmltv.c
@@ -72,13 +72,15 @@ static time_t _xmltv_str2time(const char *in)
   str[sizeof(str)-1] = '\0';
 
   /* split tz */
-  while (str[sp] && str[sp] != ' ')
+  while (str[sp] && str[sp] != ' ' && str[sp] != '+' && str[sp] != '-')
+    sp++;
+  if (str[sp] == ' ')
     sp++;
 
   /* parse tz */
   // TODO: handle string TZ?
   if (str[sp]) {
-    sscanf(str+sp+1, "%d", &tz);
+    sscanf(str+sp, "%d", &tz);
     tz = (tz % 100) + (tz / 100) * 3600; // Convert from HHMM to seconds
     str[sp] = 0;
   }

@dhead666
Copy link
Contributor Author

dhead666 commented Sep 2, 2015

Done.

@perexg
Copy link
Contributor

perexg commented Sep 2, 2015

Merged. Thanks.

@perexg perexg closed this Sep 2, 2015
@dhead666
Copy link
Contributor Author

dhead666 commented Sep 2, 2015

Thanks, can this backported into 4.0.x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants