@@ -14,6 +14,24 @@ import (
14
14
"testing"
15
15
)
16
16
17
+ // https://github.com/golang/go/issues/58246
18
+ const issue58246 = `<!--[if gte mso 12]>
19
+ <xml>
20
+ <o:OfficeDocumentSettings>
21
+ <o:AllowPNG/>
22
+ <o:PixelsPerInch>96</o:PixelsPerInch>
23
+ </o:OfficeDocumentSettings>
24
+ </xml>
25
+ <![endif]-->`
26
+ const issue58246Rendered = `<!--[if gte mso 12]>
27
+ <xml>
28
+ <o:OfficeDocumentSettings>
29
+ <o:AllowPNG/>
30
+ <o:PixelsPerInch>96</o:PixelsPerInch>
31
+ </o:OfficeDocumentSettings>
32
+ </xml>
33
+ <![endif]-->`
34
+
17
35
type tokenTest struct {
18
36
// A short description of the test case.
19
37
desc string
@@ -411,6 +429,78 @@ var tokenTests = []tokenTest{
411
429
"a<!--!--!<--!-->z" ,
412
430
"a$<!--!--!<--!-->$z" ,
413
431
},
432
+ {
433
+ "comment23" ,
434
+ "a<!-->-->z" ,
435
+ "a$<!-->-->$z" ,
436
+ },
437
+ {
438
+ "comment24" ,
439
+ "a<!-->>x" ,
440
+ "a$<!-->>x-->" ,
441
+ },
442
+ {
443
+ "comment25" ,
444
+ "a<!-->>" ,
445
+ "a$<!-->>-->" ,
446
+ },
447
+ {
448
+ "comment26" ,
449
+ "a<!-->>-" ,
450
+ "a$<!-->>-->" ,
451
+ },
452
+ {
453
+ "comment27" ,
454
+ "a<!-->>-->z" ,
455
+ "a$<!-->>-->$z" ,
456
+ },
457
+ {
458
+ "comment28" ,
459
+ "a<!--&>-->z" ,
460
+ "a$<!--&>-->$z" ,
461
+ },
462
+ {
463
+ "comment29" ,
464
+ "a<!--&gt;-->z" ,
465
+ "a$<!--&gt;-->$z" ,
466
+ },
467
+ {
468
+ "comment30" ,
469
+ "a<!--&nosuchentity;-->z" ,
470
+ "a$<!--&nosuchentity;-->$z" ,
471
+ },
472
+ // https://stackoverflow.design/email/base/mso/#targeting-specific-outlook-versions
473
+ // says "[For] Windows Outlook 2003 and above... conditional comments allow
474
+ // us to add bits of HTML that are only read by the Word-based versions of
475
+ // Outlook". TODO: these comments (with angle brackets) should pass through
476
+ // unchanged (by this Go package) when rendering.
477
+ //
478
+ // We should also still escape ">" as ">" when necessary.
479
+ // https://github.com/golang/go/issues/48237
480
+ //
481
+ // The "your code" example below comes from that stackoverflow.design link
482
+ // above but note that it can contain angle-bracket-rich XML.
483
+ // https://github.com/golang/go/issues/58246
484
+ {
485
+ "issue48237CommentWithAmpgtsemi1" ,
486
+ "a<!--<p></p><!--[video]-->-->z" ,
487
+ "a$<!--<p></p><!--[video]-->-->$z" ,
488
+ },
489
+ {
490
+ "issue48237CommentWithAmpgtsemi2" ,
491
+ "a<!--<p></p><!--[video]--!>-->z" ,
492
+ "a$<!--<p></p><!--[video]--!>-->$z" ,
493
+ },
494
+ {
495
+ "issue58246MicrosoftOutlookComment1" ,
496
+ "a<!--[if mso]> your code <![endif]-->z" ,
497
+ "a$<!--[if mso]> your code <![endif]-->$z" ,
498
+ },
499
+ {
500
+ "issue58246MicrosoftOutlookComment2" ,
501
+ "a" + issue58246 + "z" ,
502
+ "a$" + issue58246Rendered + "$z" ,
503
+ },
414
504
// An attribute with a backslash.
415
505
{
416
506
"backslash" ,
0 commit comments