Skip to content

Commit

Permalink
Allow whitespace around '=' in soy attributes
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131079638
  • Loading branch information
Soy Authors authored and mikesamuel committed Aug 25, 2016
1 parent 65f903a commit 7a1cb41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -53,7 +53,7 @@ public final class CommandTextAttributesParser {
* Note group(1) is attribute name, group(2) is attribute value.
* E.g. data="$boo" parses into group(1)="data" and group(2)="$boo". */
private static final Pattern ATTRIBUTE_TEXT =
Pattern.compile("([a-zA-Z][a-zA-Z0-9-]*) = \" ( (?:[^\"\\\\]+ | \\\\.)*+ ) \" \\s*",
Pattern.compile("([a-zA-Z][a-zA-Z0-9-]*) \\s* = \\s* \" ( (?:[^\"\\\\]+ | \\\\.)*+ ) \" \\s*",
Pattern.COMMENTS | Pattern.DOTALL);

/**
Expand Down Expand Up @@ -132,7 +132,6 @@ Map<String, String> parse(
int i = 0; // index in commandText that we've processed up to
Matcher matcher = ATTRIBUTE_TEXT.matcher(commandText);
while (matcher.find(i)) {

if (matcher.start() != i) {
errorReporter.report(sourceLocation, MALFORMED_ATTRIBUTES, commandName, commandText);
}
Expand Down
Expand Up @@ -295,6 +295,13 @@ public void testCommandTextErrors() {
"Invalid value for attribute 'autoescape' in 'template' command text "
+ "(autoescape=\"false\"). Valid values are "
+ "[deprecated-noncontextual, deprecated-contextual, strict].");

// assertion inside no-arg templateBasicNode() is that there is no exception.
templateBasicNode()
.setId(0)
.setCmdText(".foo autoescape =\n\t\r \"strict\"")
.setSoyDoc("/***/")
.build();
}

public void testValidStrictTemplates() {
Expand Down

0 comments on commit 7a1cb41

Please sign in to comment.