Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
592f7886
Unverified
Commit
592f7886
authored
Apr 08, 2020
by
Shi-Hao Hong
Committed by
GitHub
Apr 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove escape dollar parameter in localizations_utils (#54219)
parent
19c8948e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
25 deletions
+7
-25
localizations_utils.dart
dev/tools/localization/localizations_utils.dart
+6
-20
localizations_utils_test.dart
dev/tools/test/localization/localizations_utils_test.dart
+1
-5
No files found.
dev/tools/localization/localizations_utils.dart
View file @
592f7886
...
...
@@ -387,24 +387,9 @@ class $classNamePrefix$camelCaseName extends $superClass {''';
/// foo\\nbar => 'foo\\\\nbar'
/// foo\\bar => 'foo\\\\bar'
/// foo\ bar => 'foo\\ bar'
/// ```
///
/// When [shouldEscapeDollar] is set to true, the '$' characters in the
/// input will be replaced by '$' in the returned string:
/// ```
/// foo$bar = 'foo\$bar'
/// ```
///
/// When [shouldEscapeDollar] is set to false, '$' will be replaced
/// by '\$' in the returned string:
/// ```
/// foo$bar => 'foo\\\$bar'
/// ```
///
/// [shouldEscapeDollar] is true by default.
String
generateString
(
String
value
,
{
bool
escapeDollar
=
true
})
{
assert
(
escapeDollar
!=
null
);
String
generateString
(
String
value
)
{
const
String
backslash
=
'__BACKSLASH__'
;
assert
(
!
value
.
contains
(
backslash
),
...
...
@@ -412,12 +397,12 @@ String generateString(String value, { bool escapeDollar = true }) {
'"__BACKSLASH__", as it is used as part of '
'backslash character processing.'
);
value
=
value
.
replaceAll
(
'
\\
'
,
backslash
);
if
(
escapeDollar
)
value
=
value
.
replaceAll
(
'
\$
'
,
'
\\
\$
'
);
value
=
value
// Replace backslashes with a placeholder for now to properly parse
// other special characters.
.
replaceAll
(
'
\\
'
,
backslash
)
.
replaceAll
(
'
\$
'
,
'
\\
\$
'
)
.
replaceAll
(
"'"
,
"
\\
'"
)
.
replaceAll
(
'"'
,
'
\\
"'
)
.
replaceAll
(
'
\n
'
,
'
\\
n'
)
...
...
@@ -425,6 +410,7 @@ String generateString(String value, { bool escapeDollar = true }) {
.
replaceAll
(
'
\t
'
,
'
\\
t'
)
.
replaceAll
(
'
\r
'
,
'
\\
r'
)
.
replaceAll
(
'
\
b'
,
'
\\
b'
)
// Reintroduce escaped backslashes into generated Dart string.
.
replaceAll
(
backslash
,
'
\\\\
'
);
return
"'
$value
'"
;
...
...
dev/tools/test/localization/localizations_utils_test.dart
View file @
592f7886
...
...
@@ -37,11 +37,7 @@ void main() {
});
test
(
'escapes dollar when escapeDollar is true'
,
()
{
expect
(
generateString
(
r'ab$c'
,
escapeDollar:
true
),
"'ab
\\
\
$c
'"
);
});
test
(
'does not escape dollar when escapeDollar is false'
,
()
{
expect
(
generateString
(
r'ab$c'
,
escapeDollar:
false
),
"'ab
\
$c
'"
);
expect
(
generateString
(
r'ab$c'
),
"'ab
\\
\
$c
'"
);
});
test
(
'handles backslash'
,
()
{
...
...
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