Skip to content

Commit cab2242

Browse files
committed
Merge branch '2.4.x' of github.com:grails/grails-core into 2.4.x
2 parents ef869e3 + cf0f5b0 commit cab2242

File tree

8 files changed

+93
-16
lines changed

8 files changed

+93
-16
lines changed

grails-databinding/src/test/groovy/org/grails/databinding/converters/CurrencyConversionSpec.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CurrencyConversionSpec extends Specification {
1818

1919
then:
2020
bank.currency instanceof Currency
21-
'$' == bank.currency.symbol
21+
'USD' == bank.currency.currencyCode
2222
}
2323
}
2424

grails-encoder/src/main/groovy/org/codehaus/groovy/grails/plugins/codecs/BasicCodecLookup.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727
import org.codehaus.groovy.grails.support.encoding.CodecLookup;
2828
import org.codehaus.groovy.grails.support.encoding.Decoder;
2929
import org.codehaus.groovy.grails.support.encoding.Encoder;
30+
import org.codehaus.groovy.grails.support.encoding.StreamingEncoder;
3031
import org.springframework.beans.factory.InitializingBean;
3132

3233
public class BasicCodecLookup implements CodecLookup, InitializingBean {
3334
private static final String NONE_CODEC_NAME = "none";
3435
protected Map<String, Encoder> encoders;
3536
protected Map<String, Decoder> decoders;
36-
public static final Encoder NONE_ENCODER = new NoneEncoder();
37+
public static final StreamingEncoder NONE_ENCODER = new NoneEncoder();
3738

3839
public BasicCodecLookup() {
3940
super();

grails-encoder/src/main/groovy/org/codehaus/groovy/grails/support/encoding/DefaultEncodingStateRegistry.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import java.util.Map;
2222
import java.util.Set;
2323

24+
import org.codehaus.groovy.grails.plugins.codecs.BasicCodecLookup;
25+
2426
/**
2527
* default implementation of {@link EncodingStateRegistry}
2628
*
@@ -29,7 +31,7 @@
2931
*/
3032
public final class DefaultEncodingStateRegistry implements EncodingStateRegistry {
3133
private Map<Encoder, Set<Integer>> encodingTagIdentityHashCodes = new HashMap<Encoder, Set<Integer>>();
32-
public static Encoder NONE_ENCODER;
34+
public static final StreamingEncoder NONE_ENCODER = BasicCodecLookup.NONE_ENCODER;
3335

3436
private Set<Integer> getIdentityHashCodesForEncoder(Encoder encoder) {
3537
Set<Integer> identityHashCodes = encodingTagIdentityHashCodes.get(encoder);

grails-encoder/src/main/groovy/org/codehaus/groovy/grails/web/util/GrailsPrintWriter.java

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,40 @@ protected Writer unwrapWriter(Writer writer) {
9494
* Provides Groovy << left shift operator, but intercepts call to make sure
9595
* nulls are converted to "" strings
9696
*
97-
* @param value The value
97+
* @param obj The value
9898
* @return Returns this object
9999
* @throws IOException
100100
*/
101-
public GrailsPrintWriter leftShift(Object value) throws IOException {
102-
usageFlag = true;
103-
if (value != null) {
104-
InvokerHelper.write(this, value);
101+
public GrailsPrintWriter leftShift(Object obj) throws IOException {
102+
if (trouble || obj == null) {
103+
usageFlag = true;
104+
return this;
105+
}
106+
107+
Class<?> clazz = obj.getClass();
108+
if (clazz == String.class) {
109+
write((String)obj);
110+
}
111+
else if (clazz == StreamCharBuffer.class) {
112+
write((StreamCharBuffer)obj);
113+
}
114+
else if (clazz == GStringImpl.class) {
115+
write((Writable)obj);
116+
}
117+
else if (obj instanceof Writable) {
118+
write((Writable)obj);
119+
}
120+
else if (obj instanceof CharSequence) {
121+
try {
122+
usageFlag = true;
123+
getOut().append((CharSequence)obj);
124+
}
125+
catch (IOException e) {
126+
handleIOException(e);
127+
}
128+
}
129+
else {
130+
InvokerHelper.write(this, obj);
105131
}
106132
return this;
107133
}
@@ -517,6 +543,11 @@ public void write(final Writable writable) {
517543
}
518544

519545
protected void writeWritable(final Writable writable) {
546+
if(writable.getClass() == StreamCharBuffer.class) {
547+
write((StreamCharBuffer)writable);
548+
return;
549+
}
550+
520551
usageFlag = true;
521552
if (trouble)
522553
return;

grails-test-suite-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/GrailsWebDataBinderSpec.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ class GrailsWebDataBinderSpec extends Specification {
13311331

13321332
then:
13331333
publisher.localCurrency instanceof Currency
1334-
'$' == publisher.localCurrency.symbol
1334+
'USD' == publisher.localCurrency.currencyCode
13351335
}
13361336
}
13371337

grails-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/web/sitemesh/FullSitemeshLifeCycleTests.groovy

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,46 @@ class FullSitemeshLifeCycleTests extends AbstractGrailsTagTests {
192192

193193
assertEquals 'good', result
194194
}
195+
196+
// GRAILS-11484
197+
void testMultilineTitle() {
198+
def template = '''
199+
<html>
200+
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
201+
<title>
202+
This is the title
203+
</title></head>
204+
<body onload="test();">body text</body>
205+
</html>
206+
'''
207+
208+
assertOutputEquals '''
209+
<html>
210+
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
211+
<title>
212+
This is the title
213+
</title></head>
214+
<body onload="test();">body text</body>
215+
</html>
216+
''', template
217+
218+
def layout = '''
219+
<html>
220+
<head><title>Decorated <g:layoutTitle /></title><g:layoutHead /></head>
221+
<body><h1>Hello</h1><g:layoutBody /></body>
222+
</html>
223+
'''
224+
def result = applyLayout(layout, template)
225+
226+
assertEquals '''
227+
<html>
228+
<head><title>Decorated
229+
This is the title
230+
</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
231+
</head>
232+
<body><h1>Hello</h1>body text</body>
233+
</html>
234+
''', result
235+
}
236+
195237
}

grails-web-gsp/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageOutputStack.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ public static GroovyPageOutputStack currentStack(boolean allowCreate) {
5151
}
5252

5353
public static GroovyPageOutputStack currentStack(GrailsWebRequest request, boolean allowCreate) {
54-
if (allowCreate) {
55-
return currentStack(request, allowCreate, null, allowCreate, false);
54+
GroovyPageOutputStack outputStack = lookupStack(request);
55+
if (outputStack == null && allowCreate) {
56+
outputStack = currentStack(request, allowCreate, null, allowCreate, false);
5657
}
57-
return lookupStack(request);
58+
return outputStack;
5859
}
5960

6061
public static GroovyPageOutputStack currentStack(boolean allowCreate, Writer topWriter, boolean autoSync, boolean pushTop) {
@@ -75,16 +76,16 @@ public static GroovyPageOutputStack currentStack(GroovyPageOutputStackAttributes
7576
}
7677

7778
if (attributes.isAllowCreate()) {
78-
if (attributes.getTopWriter() == null) {
79-
attributes=new GroovyPageOutputStackAttributes.Builder(attributes).topWriter(lookupRequestWriter(attributes.getWebRequest())).build();
80-
}
8179
return createNew(attributes);
8280
}
8381

8482
return null;
8583
}
8684

8785
private static final GroovyPageOutputStack createNew(GroovyPageOutputStackAttributes attributes) {
86+
if (attributes.getTopWriter() == null) {
87+
attributes=new GroovyPageOutputStackAttributes.Builder(attributes).topWriter(lookupRequestWriter(attributes.getWebRequest())).build();
88+
}
8889
GroovyPageOutputStack instance = new GroovyPageOutputStack(attributes);
8990
attributes.getWebRequest().setAttribute(
9091
ATTRIBUTE_NAME_OUTPUT_STACK, instance, RequestAttributes.SCOPE_REQUEST);

grails-web-sitemesh/src/main/groovy/org/codehaus/groovy/grails/web/sitemesh/GSPSitemeshPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void writeHead(Writer out) throws IOException {
9393
}
9494
String headAsString = headBuffer.toString();
9595
// strip out title for sitemesh version of <head>
96-
out.write(headAsString.replaceFirst("<title(\\s[^>]*)?>(.*?)</title>",""));
96+
out.write(headAsString.replaceFirst("(?is)<title(\\s[^>]*)?>(.*?)</title>",""));
9797
}
9898
else {
9999
headBuffer.writeTo(out);

0 commit comments

Comments
 (0)