Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
audiowmark
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
audiowmark
Commits
c74905ab
Commit
c74905ab
authored
Jan 18, 2024
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deal with special chars that need escaping for gen-key --name.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
ac2a3157
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
audiowmark.cc
src/audiowmark.cc
+15
-9
No files found.
src/audiowmark.cc
View file @
c74905ab
...
...
@@ -400,28 +400,34 @@ test_resample (const string& in_file, const string& out_file, int new_rate)
return
0
;
}
static
void
check
_key_name
(
const
string
&
name
)
static
string
escape
_key_name
(
const
string
&
name
)
{
for
(
auto
ch
:
name
)
string
result
;
for
(
unsigned
int
ch
:
name
)
{
if
((
ch
>=
'A'
&&
ch
<=
'Z'
)
||
(
ch
>=
'a'
&&
ch
<=
'z'
)
||
(
ch
>=
'0'
&&
ch
<=
'9'
)
||
ch
==
' '
||
ch
==
'-'
||
ch
==
'_'
)
if
(
ch
==
'"'
||
ch
==
'\\'
)
{
// fine
result
+=
'\\'
;
result
+=
ch
;
}
else
if
(
ch
>=
32
)
// ASCII, UTF-8
{
result
+=
ch
;
}
else
{
error
(
"audiowmark: bad key name:
'%c'
is not allowed as character in key names
\n
"
,
ch
);
error
(
"audiowmark: bad key name:
%d
is not allowed as character in key names
\n
"
,
ch
);
exit
(
1
);
}
}
return
result
;
}
int
gen_key
(
const
string
&
outfile
,
const
string
&
key_name
)
{
check
_key_name
(
key_name
);
string
ename
=
escape
_key_name
(
key_name
);
FILE
*
f
=
fopen
(
outfile
.
c_str
(),
"w"
);
if
(
!
f
)
...
...
@@ -431,7 +437,7 @@ gen_key (const string& outfile, const string& key_name)
}
fprintf
(
f
,
"# watermarking key for audiowmark
\n\n
key %s
\n
"
,
Random
::
gen_key
().
c_str
());
if
(
key_name
!=
""
)
fprintf
(
f
,
"name
\"
%s
\"\n
"
,
key_
name
.
c_str
());
fprintf
(
f
,
"name
\"
%s
\"\n
"
,
e
name
.
c_str
());
fclose
(
f
);
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment