Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(798)

Unified Diff: pkg/yaml/lib/composer.dart

Issue 12876003: Fix escaping in YAML RegExp. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use raw strings for regexes. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/yaml/lib/composer.dart
diff --git a/pkg/yaml/lib/composer.dart b/pkg/yaml/lib/composer.dart
index e22159f34c30f73a06c4911a83ad63efda5ac56e..90ed3308eddc1bdb5a57002aa3b01d2bfbeaa855 100644
--- a/pkg/yaml/lib/composer.dart
+++ b/pkg/yaml/lib/composer.dart
@@ -98,13 +98,13 @@ class _Composer extends _Visitor {
/// Parses a null scalar.
_ScalarNode parseNull(String content) {
- if (!new RegExp("^(null|Null|NULL|~|)\$").hasMatch(content)) return null;
+ if (!new RegExp(r"^(null|Null|NULL|~|)$").hasMatch(content)) return null;
return new _ScalarNode(_Tag.yaml("null"), value: null);
}
/// Parses a boolean scalar.
_ScalarNode parseBool(String content) {
- var match = new RegExp("^(?:(true|True|TRUE)|(false|False|FALSE))\$").
+ var match = new RegExp(r"^(?:(true|True|TRUE)|(false|False|FALSE))$").
firstMatch(content);
if (match == null) return null;
return new _ScalarNode(_Tag.yaml("bool"), value: match.group(1) != null);
@@ -112,19 +112,19 @@ class _Composer extends _Visitor {
/// Parses an integer scalar.
_ScalarNode parseInt(String content) {
- var match = new RegExp("^[-+]?[0-9]+\$").firstMatch(content);
+ var match = new RegExp(r"^[-+]?[0-9]+$").firstMatch(content);
if (match != null) {
return new _ScalarNode(_Tag.yaml("int"),
value: int.parse(match.group(0)));
}
- match = new RegExp("^0o([0-7]+)\$").firstMatch(content);
+ match = new RegExp(r"^0o([0-7]+)$").firstMatch(content);
if (match != null) {
int n = int.parse(match.group(1), radix: 8);
return new _ScalarNode(_Tag.yaml("int"), value: n);
}
- match = new RegExp("^0x[0-9a-fA-F]+\$").firstMatch(content);
+ match = new RegExp(r"^0x[0-9a-fA-F]+$").firstMatch(content);
if (match != null) {
return new _ScalarNode(_Tag.yaml("int"),
value: int.parse(match.group(0)));
@@ -136,7 +136,7 @@ class _Composer extends _Visitor {
/// Parses a floating-point scalar.
_ScalarNode parseFloat(String content) {
var match = new RegExp(
- "^[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?\$").
+ r"^[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?$").
firstMatch(content);
if (match != null) {
// YAML allows floats of the form "0.", but Dart does not. Fix up those
@@ -146,13 +146,13 @@ class _Composer extends _Visitor {
value: double.parse(matchStr));
}
- match = new RegExp("^([+-]?)\.(inf|Inf|INF)\$").firstMatch(content);
+ match = new RegExp(r"^([+-]?)\.(inf|Inf|INF)$").firstMatch(content);
if (match != null) {
var value = match.group(1) == "-" ? -double.INFINITY : double.INFINITY;
return new _ScalarNode(_Tag.yaml("float"), value: value);
}
- match = new RegExp("^\.(nan|NaN|NAN)\$").firstMatch(content);
+ match = new RegExp(r"^\.(nan|NaN|NAN)$").firstMatch(content);
if (match != null) {
return new _ScalarNode(_Tag.yaml("float"), value: double.NAN);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698