OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:convert'; | 5 import 'dart:convert'; |
6 | 6 |
7 import '../log/log.dart'; | 7 import '../log/log.dart'; |
8 import '../server.dart'; | 8 import '../server.dart'; |
9 | 9 |
10 typedef void Writer(StringSink sink); | 10 typedef void Writer(StringSink sink); |
(...skipping 30 matching lines...) Expand all Loading... |
41 lastTime.codeUnitAt(prefixLength)) { | 41 lastTime.codeUnitAt(prefixLength)) { |
42 prefixLength++; | 42 prefixLength++; |
43 } | 43 } |
44 return prefixLength; | 44 return prefixLength; |
45 } | 45 } |
46 | 46 |
47 /** | 47 /** |
48 * Return an escaped version of the given [unsafe] text. | 48 * Return an escaped version of the given [unsafe] text. |
49 */ | 49 */ |
50 String escape(String unsafe) { | 50 String escape(String unsafe) { |
51 return htmlEscape.convert(unsafe); | 51 // We double escape single quotes because the escaped characters are |
| 52 // processed as part of reading the HTML, which means that single quotes |
| 53 // end up terminating string literals too early when they appear in event |
| 54 // handlers (which in turn leads to JavaScript syntax errors). |
| 55 return htmlEscape.convert(unsafe).replaceAll(''', '''); |
52 } | 56 } |
53 | 57 |
54 /** | 58 /** |
55 * Write the body of the page (without the 'body' tag) to the given [sink]. | 59 * Write the body of the page (without the 'body' tag) to the given [sink]. |
56 */ | 60 */ |
57 void writeBody(StringSink sink); | 61 void writeBody(StringSink sink); |
58 | 62 |
59 /** | 63 /** |
60 * Write the given [date] to the given [sink]. | 64 * Write the given [date] to the given [sink]. |
61 */ | 65 */ |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 } | 270 } |
267 | 271 |
268 /** | 272 /** |
269 * Write to the given [sink] the HTML required to display content in two | 273 * Write to the given [sink] the HTML required to display content in two |
270 * columns. The content of the columns will be written by the functions | 274 * columns. The content of the columns will be written by the functions |
271 * [writeLeftColumn] and [writeRightColumn] and will be contained in 'div' | 275 * [writeLeftColumn] and [writeRightColumn] and will be contained in 'div' |
272 * elements with the id's [leftColumnId] and [rightColumnId]. | 276 * elements with the id's [leftColumnId] and [rightColumnId]. |
273 */ | 277 */ |
274 void writeTwoColumns(StringSink sink, String leftColumnId, | 278 void writeTwoColumns(StringSink sink, String leftColumnId, |
275 Writer writeLeftColumn, String rightColumnId, Writer writeRightColumn) { | 279 Writer writeLeftColumn, String rightColumnId, Writer writeRightColumn) { |
276 sink.writeln('<div>'); | 280 sink.writeln('<div id="container">'); |
277 sink.writeln(' <div>'); | 281 sink.writeln(' <div id="content">'); |
278 sink.writeln(' <div id="$leftColumnId">'); | 282 sink.writeln(' <div id="$leftColumnId">'); |
279 sink.writeln(' <div class="inset">'); | 283 sink.writeln(' <div class="inset">'); |
280 writeLeftColumn(sink); | 284 writeLeftColumn(sink); |
281 sink.writeln(' </div>'); | 285 sink.writeln(' </div>'); |
282 sink.writeln(' </div>'); | 286 sink.writeln(' </div>'); |
283 sink.writeln(' <div id="$rightColumnId">'); | 287 sink.writeln(' <div id="$rightColumnId">'); |
284 sink.writeln(' <div class="inset">'); | 288 sink.writeln(' <div class="inset">'); |
285 writeRightColumn(sink); | 289 writeRightColumn(sink); |
286 sink.writeln(' </div>'); | 290 sink.writeln(' </div>'); |
287 sink.writeln(' </div>'); | 291 sink.writeln(' </div>'); |
(...skipping 16 matching lines...) Expand all Loading... |
304 } | 308 } |
305 #$rightColumnId { | 309 #$rightColumnId { |
306 float: right; | 310 float: right; |
307 height: 100%; | 311 height: 100%; |
308 overflow: auto; | 312 overflow: auto; |
309 width: 50%; | 313 width: 50%; |
310 } | 314 } |
311 '''); | 315 '''); |
312 } | 316 } |
313 } | 317 } |
OLD | NEW |