<commit_before>/*
 * Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file
 * for details. All rights reserved. Use of this source code is governed by a
 * BSD-style license that can be found in the LICENSE file.
 */
/**
 * @description Test that innerHTML does not mangle javascript: urls.
 */
import "dart:html";
import "../../../Utils/expect.dart";
import "../../testcommon.dart";

main() {
  var body = document.body;

  body.setInnerHtml('''
<div id=console></div>
<div id=jsurltest><a href='
 javascript:test(&37;3C!--D--&37;3E)'>link</a></div>
''', treeSanitizer: new NullTreeSanitizer());

  var r = document.getElementById('jsurltest');

  r.setInnerHtml(r.innerHtml.replaceAll('&37;3C!--D--&37;3E', '123'),
      treeSanitizer: new NullTreeSanitizer());
  Expect.isTrue(r.innerHtml.indexOf('javascript:test(123)') > -1, 'test 1');
  
  r.firstChild.setAttribute('href', 'javascript:test("text<")');
  Expect.isTrue(r.innerHtml.indexOf('javascript:test("text<")') > -1, 'test 2');

  r.firstChild.setAttribute('href', "javascript:test('text>')");
  Expect.isTrue(r.innerHtml.indexOf("javascript:test('text>')") > -1, 'test 3');

  var testString = '''javascript:test('text&',"test2&")''';
  r.firstChild.setAttribute('href', testString);
  Expect.isTrue(r.innerHtml.indexOf('''javascript:test('text&',&quot;test2&&quot;)''') > -1, 'test 4');
  
  r.firstChild.setAttribute('href', 'http://www.google.fi/search?q=<NAME>&meta=&btnG=Google-haku');
}
<commit_msg>Fix for issue#34. Quotes in strings should be escaped<commit_after>/*
 * Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file
 * for details. All rights reserved. Use of this source code is governed by a
 * BSD-style license that can be found in the LICENSE file.
 */
/**
 * @description Test that innerHTML does not mangle javascript: urls.
 */
import "dart:html";
import "../../../Utils/expect.dart";
import "../../testcommon.dart";

main() {
  var body = document.body;

  body.setInnerHtml('''
<div id=console></div>
<div id=jsurltest><a href='
 javascript:test(&37;3C!--D--&37;3E)'>link</a></div>
''', treeSanitizer: new NullTreeSanitizer());

  var r = document.getElementById('jsurltest');

  r.setInnerHtml(r.innerHtml.replaceAll('&amp;37;3C!--D--&amp;37;3E', '123'),
      treeSanitizer: new NullTreeSanitizer());

  Expect.isTrue(r.innerHtml.indexOf('javascript:test(123)') > -1, 'Test point 1');

  r.firstChild.setAttribute('href', 'javascript:test("text<")');
  Expect.isTrue(r.innerHtml.indexOf('javascript:test("text<")') > -1, 'Test point 2');

  r.firstChild.setAttribute('href', "javascript:test('text>')");
  Expect.isTrue(r.innerHtml.indexOf("javascript:test('text>')") > -1, 'Test point 3');

  var testString = '''javascript:test('text&',"test2&")''';
  r.firstChild.setAttribute('href', testString);
  Expect.isTrue(r.innerHtml.indexOf('''javascript:test('text&amp;',&quot;test2&amp;&quot;)''') > -1, 'Test point 4');
  
  r.firstChild.setAttribute('href', 'http://www.google.fi/search?q=<NAME>&meta=&btnG=Google-haku');
}

{'fraction_non_alphanumeric': 0.20804710500490678, 'fraction_numerical': 0.021589793915603533, 'mean_word_length': 5.079522862823062, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7052939', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1046, 'n_words': 214}