Merge pull request #99 from hdevalke/master
Do not quote hyphenated strings unnecessarily.
This commit is contained in:
commit
5990b5c427
3 changed files with 14 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
|||
language: rust
|
||||
rust:
|
||||
- 1.22.1
|
||||
- 1.16.0
|
||||
- 1.18.0
|
||||
- beta
|
||||
- nightly
|
||||
matrix:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
install:
|
||||
- ps: Start-FileDownload 'https://static.rust-lang.org/dist/rust-1.16.0-i686-pc-windows-gnu.exe'
|
||||
- rust-1.16.0-i686-pc-windows-gnu.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
|
||||
- ps: Start-FileDownload 'https://static.rust-lang.org/dist/rust-1.18.0-i686-pc-windows-gnu.exe'
|
||||
- rust-1.18.0-i686-pc-windows-gnu.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
|
||||
- SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin
|
||||
- SET PATH=%PATH%;C:\MinGW\bin
|
||||
- rustc -V
|
||||
|
|
|
@ -281,8 +281,10 @@ impl<'a> YamlEmitter<'a> {
|
|||
}
|
||||
|
||||
/// Check if the string requires quoting.
|
||||
/// Strings starting with any of the following characters must be quoted.
|
||||
/// :, &, *, ?, |, -, <, >, =, !, %, @
|
||||
/// Strings containing any of the following characters must be quoted.
|
||||
/// :, {, }, [, ], ,, &, *, #, ?, |, -, <, >, =, !, %, @, `
|
||||
/// {, }, [, ], ,, #, `
|
||||
///
|
||||
/// If the string contains any of the following control characters, it must be escaped with double quotes:
|
||||
/// \0, \x01, \x02, \x03, \x04, \x05, \x06, \a, \b, \t, \n, \v, \f, \r, \x0e, \x0f, \x10, \x11, \x12, \x13, \x14, \x15, \x16, \x17, \x18, \x19, \x1a, \e, \x1c, \x1d, \x1e, \x1f, \N, \_, \L, \P
|
||||
|
@ -300,9 +302,15 @@ fn need_quotes(string: &str) -> bool {
|
|||
|
||||
string == ""
|
||||
|| need_quotes_spaces(string)
|
||||
|| string.starts_with(|character: char| {
|
||||
match character {
|
||||
':' | '&' | '*' | '?' | '|' | '-' | '<' | '>' | '=' | '!' | '%' | '@' => true,
|
||||
_ => false,
|
||||
}
|
||||
})
|
||||
|| string.contains(|character: char| {
|
||||
match character {
|
||||
':' | '{' | '}' | '[' | ']' | ',' | '&' | '*' | '#' | '?' | '|' | '-' | '<' | '>' | '=' | '!' | '%' | '@' | '`' | '\"' | '\'' | '\\' | '\0' ... '\x06' | '\t' | '\n' | '\r' | '\x0e' ... '\x1a' | '\x1c' ... '\x1f' => true,
|
||||
'{' | '}' | '[' | ']' | ',' | '#' | '`' | '\"' | '\'' | '\\' | '\0' ... '\x06' | '\t' | '\n' | '\r' | '\x0e' ... '\x1a' | '\x1c' ... '\x1f' => true,
|
||||
_ => false,
|
||||
}
|
||||
})
|
||||
|
@ -402,7 +410,7 @@ products:
|
|||
a7: 你好
|
||||
boolean: "true"
|
||||
boolean2: "false"
|
||||
date: "2014-12-31"
|
||||
date: 2014-12-31
|
||||
empty_string: ""
|
||||
empty_string1: " "
|
||||
empty_string2: " a"
|
||||
|
|
Loading…
Reference in a new issue