Skip to content

Commit

Permalink
Issue #12 fix
Browse files Browse the repository at this point in the history
Issue #12 fix.
  • Loading branch information
coffeegreg committed Dec 16, 2023
1 parent 61bbfbc commit 0159a99
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 17 additions & 1 deletion src/common.pas
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface

const
APP_NAME = 'YTuner';
APP_VERSION = '1.1.0';
APP_VERSION = '1.1.1';
APP_COPYRIGHT = 'Copyright (c) 2023 Greg P. (https://github.com/coffeegreg)';
INI_VERSION = '1.1.0';

Expand Down Expand Up @@ -104,6 +104,7 @@ function RemoveEscChars(LInputStr: RawByteString): RawByteString;
function HaveCommonElements(AStr: string; AStrArray: array of string): boolean;
function ContainsIn(AStr: string; AStrArray: array of string): boolean;
function StripChars(AInputString: string):string;
function URLEncode(const AStr: String): AnsiString;

implementation

Expand Down Expand Up @@ -235,6 +236,21 @@ function StripChars(AInputString: string):string;
Result:=DelSpace1(StringsReplace(AInputString,STRIP_CHARS,(DupeString(' ,',Length(STRIP_CHARS)-1)+' ').Split([',']),[rfReplaceAll]).Trim);
end;

function URLEncode(const AStr: String): AnsiString;
var
LAnsiChar: AnsiChar;
begin
Result:='';
for LAnsiChar in AStr do
begin
if ((Ord(LAnsiChar)<65) or (Ord(LAnsiChar)>90))
and ((Ord(LAnsiChar)<97) or (Ord(LAnsiChar)>122)) then
Result:=Result+'%'+IntToHex(Ord(LAnsiChar),2)
else
Result:=Result+LAnsiChar;
end;
end;

end.


4 changes: 2 additions & 2 deletions src/httpserver.pas
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ procedure GetMyStationsCategories(AReq: TRequest; ARes: TResponse);
begin
for i:=LFirstElement to LLastElement do
with MyStations[i] do
LMyPage.Add(SetVTunerDirectory(MSCategory,PATH_ROOT+'/'+PATH_MY_STATIONS+'/'+MSCategory,Length(MSStations)));
LMyPage.Add(SetVTunerDirectory(MSCategory,PATH_ROOT+'/'+PATH_MY_STATIONS+'/'+URLEncode(MSCategory),Length(MSStations)));
SendPageResponse(HTTP_CODE_OK,ctXML,ARes,LMyPage);
end
else
Expand Down Expand Up @@ -552,7 +552,7 @@ procedure GetRadioBrowserCategoryType(AReq: TRequest; ARes: TResponse);
LMyPage.TotalItemsCount:=LRBCategories.Count;
for i:=LFirstElement to LLastElement do
with TRBCategory(LRBCategories.Objects[i]) do
LMyPage.Add(SetVTunerDirectory(RBCName,PATH_ROOT+'/'+PATH_RADIOBROWSER+'/'+PATH_RADIOBROWSER_CATEGORIES[LCategoryIdx]+'/'+RBCName,RBCMaxCount));
LMyPage.Add(SetVTunerDirectory(RBCName,PATH_ROOT+'/'+PATH_RADIOBROWSER+'/'+PATH_RADIOBROWSER_CATEGORIES[LCategoryIdx]+'/'+URLEncode(RBCName),RBCMaxCount));
SendPageResponse(HTTP_CODE_OK,ctXML,ARes,LMyPage);
finally
LMyPage.Free;
Expand Down

0 comments on commit 0159a99

Please sign in to comment.