@@ -400,25 +400,21 @@ func TestValidateNoteMarkdown(t *testing.T) {
400400 tests := []struct {
401401 name string
402402 content string
403- expectError bool
404403 description string
405404 }{
406405 {
407406 name : "Valid Markdown with headings" ,
408407 content : "# Heading 1\n ## Heading 2\n ### Heading 3" ,
409- expectError : false ,
410408 description : "Standard Markdown headings should be allowed" ,
411409 },
412410 {
413411 name : "Valid Markdown with code block containing JSON" ,
414412 content : "```json\n {\" option_key_1\" : true, \" option_key_2\" : \" value\" }\n ```" ,
415- expectError : false ,
416413 description : "JSON in code blocks should not trigger false positives" ,
417414 },
418415 {
419416 name : "Valid Markdown with inline code" ,
420417 content : "Use the `onclick` handler in your code" ,
421- expectError : false ,
422418 description : "Code references to event handlers should be allowed" ,
423419 },
424420 {
@@ -484,98 +480,77 @@ class LocalizationDeDuplicator:
484480 with open(self.locale_file_path, 'r', encoding='utf-8') as f:
485481 self.localization_data = json.load(f)
486482` + "```" + `` ,
487- expectError : false ,
488483 description : "Complex real-world Markdown example should be allowed" ,
489484 },
490485 {
491486 name : "HTML script tag allowed (sanitized in handler)" ,
492487 content : "This is a note with <script>alert('xss')</script> dangerous content" ,
493- expectError : false ,
494488 description : "Script tags pass validation; sanitized by bluemonday in the handler layer" ,
495489 },
496490 {
497491 name : "HTML with onclick handler allowed (sanitized in handler)" ,
498492 content : "Click <a href='#' onclick='alert(1)'>here</a>" ,
499- expectError : false ,
500493 description : "HTML with event handlers passes validation; sanitized by bluemonday in the handler layer" ,
501494 },
502495 {
503496 name : "Iframe tag allowed (sanitized in handler)" ,
504497 content : "Embedded content: <iframe src='http://evil.com'></iframe>" ,
505- expectError : false ,
506498 description : "Iframe tags pass validation; sanitized by bluemonday in the handler layer" ,
507499 },
508500 {
509501 name : "HTML img tag allowed (sanitized in handler)" ,
510502 content : "Image: <img src='x' onerror='alert(1)'>" ,
511- expectError : false ,
512503 description : "HTML img tags pass validation; sanitized by bluemonday in the handler layer" ,
513504 },
514505 {
515506 name : "Valid Markdown with link" ,
516507 content : "Check out [this link](https://example.com)" ,
517- expectError : false ,
518508 description : "Markdown links should be allowed" ,
519509 },
520510 {
521511 name : "Valid Markdown with image" ,
522512 content : "" ,
523- expectError : false ,
524513 description : "Markdown images should be allowed" ,
525514 },
526515 {
527516 name : "Valid empty content" ,
528517 content : "" ,
529- expectError : false ,
530518 description : "Empty content should pass validation (required validation is separate)" ,
531519 },
532520 {
533521 name : "HTML paragraph tag allowed (sanitized in handler)" ,
534522 content : "<p>This is HTML</p>" ,
535- expectError : false ,
536523 description : "HTML paragraph tags pass validation; sanitized by bluemonday in the handler layer" ,
537524 },
538525 {
539526 name : "HTML div tag allowed (sanitized in handler)" ,
540527 content : "<div class='container'>Content</div>" ,
541- expectError : false ,
542528 description : "HTML div tags pass validation; sanitized by bluemonday in the handler layer" ,
543529 },
544530 {
545531 name : "Valid Markdown with special characters" ,
546532 content : "Special chars: & < > \" ' are allowed in plain text" ,
547- expectError : false ,
548533 description : "Special characters in plain text should be allowed" ,
549534 },
550535 {
551- name : "Template expression rejected " ,
536+ name : "Template expression allowed in markdown " ,
552537 content : "Hello {{ user }} world" ,
553- expectError : true ,
554- description : "Template expressions should be rejected" ,
538+ description : "Template expressions are permitted in markdown content" ,
555539 },
556540 {
557- name : "Template expression in code block allowed" ,
558- content : "```\n {{ user }}\n ```" ,
559- expectError : false ,
560- description : "Template expressions in code blocks should be allowed" ,
561- },
562- {
563- name : "Template expression in inline code allowed" ,
564- content : "Use `{{ template }}` syntax" ,
565- expectError : false ,
566- description : "Template expressions in inline code should be allowed" ,
567- },
568- {
569- name : "JavaScript template literal rejected" ,
541+ name : "JavaScript template literal allowed in markdown" ,
570542 content : "Hello ${ name } world" ,
571- expectError : true ,
572- description : "JavaScript template interpolation should be rejected" ,
543+ description : "Template interpolation is permitted in markdown content" ,
573544 },
574545 {
575- name : "Server template tag rejected " ,
546+ name : "Server template tag allowed in markdown " ,
576547 content : "Hello <% code %> world" ,
577- expectError : true ,
578- description : "Server template tags should be rejected" ,
548+ description : "Server template tags are permitted in markdown content" ,
549+ },
550+ {
551+ name : "Terraform variable interpolation" ,
552+ content : "| OKE Cluster | `${var.name_prefix}-oke` |" ,
553+ description : "Terraform variable syntax is permitted in markdown content" ,
579554 },
580555 }
581556
@@ -587,17 +562,8 @@ class LocalizationDeDuplicator:
587562 Name : "Test Note" ,
588563 }
589564
590- // Run validation
591565 err := ValidateNoteMarkdown (note )
592-
593- if tt .expectError {
594- assert .Error (t , err , tt .description )
595- if err != nil {
596- assert .Contains (t , err .Error (), "unsafe" , "Error should mention unsafe content" )
597- }
598- } else {
599- assert .NoError (t , err , tt .description )
600- }
566+ assert .NoError (t , err , tt .description )
601567 })
602568 }
603569}
0 commit comments