[PATCH] Escape double quotes in parameters for Windows tagging applications
dinkypumpkin
dinkypumpkin at gmail.com
Mon Oct 10 14:47:46 EDT 2011
This patch addresses a problem first reported here:
http://lists.infradead.org/pipermail/get_iplayer/2011-October/002075.html
This patch has been incorporated into the get_iplayer Git repo.
Instructions for updating are here:
https://github.com/dinkypumpkin/get_iplayer/wiki/instructions
Commit message and patch follow.
In Windows, command line parameters for external applications are
processed according to Microsoft C/C++ parameter parsing rules.
This means that parameter values with embedded double quotes must
be enclosed in double quotes and the embedded double quotes must be
escaped. This patch implements the necessary escaping for AtomicParsley
and id3v2 parameters. It should not be necessary for other external
applications (e.g., RTMPDump) since they will never receive parameter
values with embedded double quotes.
---
get_iplayer | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/get_iplayer b/get_iplayer
index 640c66b..f726ca0 100755
--- a/get_iplayer
+++ b/get_iplayer
@@ -9483,6 +9483,20 @@ sub tags_from_metadata {
return $tags;
}
+# escape/enclose embedded quotes in command line parameters
+sub tags_escape_quotes {
+ my ($tags) = @_;
+ # only necessary for Windows
+ if ( $^O =~ /^MSWin32$/ ) {
+ while ( my ($key, $val) = each %$tags ) {
+ if ($val =~ /"/) {
+ $val =~ s/"/\\"/g;
+ $tags->{$key} = '"'.$val.'"';
+ }
+ }
+ }
+}
+
# add metadata tag to file
sub tag_file {
my ($self, $meta) = @_;
@@ -9587,6 +9601,8 @@ sub tag_file_id3_basic {
# make safe lyrics text as well
# can't use $tags->{lyrics} because of colons in links
$tags->{longDescription} =~ s/:/_/g;
+ # handle embedded quotes
+ tags_escape_quotes($tags);
# encode for id3v2
while ( my ($key, $val) = each %{$tags} ) {
$tags->{$key} = encode("iso-8859-1", $val);
@@ -9629,6 +9645,8 @@ sub tag_file_mp4 {
main::logger "INFO: MP4 tagging \U$meta->{ext}\E file\n";
# pretty copyright for MP4
$tags->{copyright} = "\xA9 $tags->{copyright}" if $tags->{copyright};
+ # handle embedded quotes
+ tags_escape_quotes($tags);
# encode metadata for atomicparsley
my $encoding = $opt->{tag_utf8} ? "utf8" : "iso-8859-1";
while ( my ($key, $val) = each %$tags ) {
--
1.7.7
More information about the get_iplayer
mailing list