Skip to content

Commit

Permalink
Fixed: Use URL escaping for the GetRecordingInfo and GetScheduleInfo …
Browse files Browse the repository at this point in the history
…commands to accept fields with enters inside

This fixes recording playback for in progress recordings when the description fields contains a multi-line string
  • Loading branch information
margro committed Jan 4, 2017
1 parent 3456cde commit 5fc4776
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 193 deletions.
4 changes: 4 additions & 0 deletions TVServerKodi/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.15.0.137:
- Fixed: Use URL escaping for the GetRecordingInfo and GetScheduleInfo commands to accept fields with enters inside
This fixes recording playback for in progress recordings when the description fields contains a multi-line string

1.15.0.136:
- Added: Support for detecting the recording type (TV, Radio, webstream)
- Fixed: Add additional exception handling around the GetRecordingURL() function
Expand Down
10 changes: 10 additions & 0 deletions TVServerKodi/Commands/DataWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class DataWriter
private String listSeparator = ",";
private Converter<string, string> argumentEncoder = new Converter<string, string>(Uri.EscapeDataString);
private Converter<string, string> listEncoder = new Converter<string, string>(Uri.EscapeDataString);
private bool escapeData = true;

public DataWriter(NetworkStream stream)
{
Expand All @@ -37,6 +38,7 @@ public void setHumanEncoders()
//listSeparator = Environment.NewLine;
argumentEncoder = new Converter<string, string>(getSameString);
listEncoder = new Converter<string, string>(getSameString);
escapeData = false;
}

public void setArgumentSeparator(String argSep)
Expand Down Expand Up @@ -111,6 +113,14 @@ public void write(String line)
Console.WriteLine("Socket write: " + line + commandSeparator);
writer.Flush();
}
public void write(String line, bool escapeMe)
{
if (escapeData && escapeMe)
write(Uri.EscapeDataString(line));
else
write(line);
}


public void writeBytes(Byte[] bytes)
{
Expand Down
7 changes: 6 additions & 1 deletion TVServerKodi/Commands/GetRecordingInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@ public override void handleCommand(string command, string[] arguments, ref TvCon
{
int index = Int32.Parse(arguments[0]);
bool withRTSPurl = false;
bool useUriEncoding = false;

if (arguments.Length >= 2)
{
withRTSPurl = bool.Parse(arguments[1]);
}
if (arguments.Length >= 3)
{
useUriEncoding = bool.Parse(arguments[2]);
}

result = TVServerConnection.getRecordingInfo(index, withRTSPurl);
Console.WriteLine(getCommandToHandle() + ":" + index + " " + result);

writer.write(result);
writer.write(result, useUriEncoding);
}
catch
{
Expand Down
9 changes: 7 additions & 2 deletions TVServerKodi/Commands/GetScheduleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,24 @@ public GetScheduleInfo(ConnectionHandler connection)

public override void handleCommand(string command, string[] arguments, ref TvControl.IUser me)
{
// we want to list all recordings
String result;

if (arguments != null)
{
try
{
int index = Int32.Parse(arguments[0]);
bool useUriEncoding = false;

if (arguments.Length >= 2)
{
useUriEncoding = bool.Parse(arguments[1]);
}

result = TVServerConnection.GetScheduleInfo(index);
Console.WriteLine("GetScheduleInfo:" + index + " " + result);

writer.write(result);
writer.write(result, useUriEncoding);
}
catch
{
Expand Down
Loading

0 comments on commit 5fc4776

Please sign in to comment.