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

accept "%c" placeholder for channel icons to use unmangled channel #582

Closed
wants to merge 2 commits into from

Conversation

Jalle19
Copy link
Contributor

@Jalle19 Jalle19 commented Jan 8, 2015

I have all my channel icons on a web server named exactly like the channel, e.g. "Yle TV1 HD.png". With this patch I don't have to do any renaming when mapping channels.

@perexg does tvheadend have a helper for URL-encoding strings? I'm not completely sure that the current approach works since the URL isn't escaped (spaces should be converted to %20 etc.).

@Jalle19
Copy link
Contributor Author

Jalle19 commented Jan 8, 2015

@perexg I added proper (hopefully) URL encoding

The following placeholders are available:<br>
<ul>
<li>%C - the channel name with safe characters (no spaces etc.)</li>
<li>%c - the channel name (untouched)</li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention utf8 encoding here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about it?

@Jalle19
Copy link
Contributor Author

Jalle19 commented Jan 8, 2015

@perexg is this what you meant?

@perexg
Copy link
Contributor

perexg commented Jan 8, 2015

I meant to explicitly tell the user that the encoded string is using the utf8 encoding (which internally tvheadend uses for all international/language strings).

@ProfYaffle
Copy link
Member

and while it's being debated, I'm not sure that mangled/unmangled carries the right meaning. 'Translated' or 'converted' would be better.

@Jalle19
Copy link
Contributor Author

Jalle19 commented Jan 8, 2015

@perexg in that case I read the code wrong, are you saying the resulting string is in UTF-8?

@ProfYaffle sure, there may be a better word. I believe "transliterated" is the correct one, but no one understands what that means.

@ProfYaffle
Copy link
Member

Well, 'transliteration' would certainly do, and makes sense to me - but yes, it'd probably be lost on most people... nearly as many as 'unmangled' would perhaps be.

And I'm not sure UTF-8 is the issue here, as space == ASCII 32 == UTF-8 0x20. I think the UTF-8 bit as it applies to non-ASCII characters (e.g. ö, ŵ) is necessary, but this is also about translating reserved or 'unsafe' characters, as per the URI specifications:

http://www.ietf.org/rfc/rfc1738.txt

Just trying to help, though, it's your call.

@perexg
Copy link
Contributor

perexg commented Jan 8, 2015

The chname string is utf8 string. You only encode it in %c condition (for HTTP URL), right ? I meant only to tell the user in the help, that this URL encoded channel name willl use utf8 for international characters, because it's not obvious.

@Jalle19
Copy link
Contributor Author

Jalle19 commented Jan 9, 2015

@ProfYaffle updated the help text a bit, mind taking a look?
@perexg I changed it so that %c will also receive UTF-8 to ASCII conversion before the URL encoding takes place. This seems safer. The main idea behind this anyway is to preserve spaces.

else if((send = strstr(chi, "%c"))) {
char *aname = intlconv_utf8safestr(intlconv_charset_id("ASCII", 1, 1),
chname, strlen(chname) * 2);
sname = url_encode(aname);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing NULL check for aname. The NULL can be returned if iconv() function fails for a reason.

@ProfYaffle
Copy link
Member

Go for it - we can always alter it later if folks really don't understand/disagree (e.g. 'no spaces' <> 'ASCII' for obvious reasons). But it's fine.

@Jalle19
Copy link
Contributor Author

Jalle19 commented Jan 9, 2015

@perexg added the NULL check and squashed, should be good to go.

@perexg
Copy link
Contributor

perexg commented Jan 9, 2015

Merged. Thanks.

@perexg perexg closed this Jan 9, 2015
@Jalle19 Jalle19 deleted the channel-icon-unmangled branch January 12, 2015 12:35
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

3 participants