{"action":"created","issue":{"url":"https://api.github.com/repos/sparklemotion/nokogiri/issues/1465","repository_url":"https://api.github.com/repos/sparklemotion/nokogiri","labels_url":"https://api.github.com/repos/sparklemotion/nokogiri/issues/1465/labels{/name}","comments_url":"https://api.github.com/repos/sparklemotion/nokogiri/issues/1465/comments","events_url":"https://api.github.com/repos/sparklemotion/nokogiri/issues/1465/events","html_url":"https://github.com/sparklemotion/nokogiri/issues/1465","id":154881083,"number":1465,"title":"The output of read_memory method with libxml 2.9.3 is different from the one with libxml 2.9.2","user":{"login":"junaruga","id":121989,"avatar_url":"https://avatars.githubusercontent.com/u/121989?v=3","gravatar_id":"","url":"https://api.github.com/users/junaruga","html_url":"https://github.com/junaruga","followers_url":"https://api.github.com/users/junaruga/followers","following_url":"https://api.github.com/users/junaruga/following{/other_user}","gists_url":"https://api.github.com/users/junaruga/gists{/gist_id}","starred_url":"https://api.github.com/users/junaruga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/junaruga/subscriptions","organizations_url":"https://api.github.com/users/junaruga/orgs","repos_url":"https://api.github.com/users/junaruga/repos","events_url":"https://api.github.com/users/junaruga/events{/privacy}","received_events_url":"https://api.github.com/users/junaruga/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-14T23:33:23Z","updated_at":"2016-05-16T11:18:02Z","closed_at":"2016-05-16T10:36:50Z","body":"## Summary\r\n\r\nI found that the output of read_memory method for below environment were different for each other, using read_memory testing script.\r\nCould you tell me that it is bug or not?\r\n\r\n+ nokogiri: v1.6.7.2\r\n  - libxml2: 2.9.2\r\n+ nokogiri: latest master branch,  commit fe57e9080a8f1c238c706f0599d5fcfaeea33f8c\r\n  - libxml2: 2.9.3\r\n\r\n## Testing script for read_memory method\r\n\r\nI prepared the testing script to test read_memory method that is c library (ext/nokogiri/).\r\n\r\nYou can download from below URL,\r\n[test_nokogiri.rb.txt](https://github.com/sparklemotion/nokogiri/files/264748/test_nokogiri.rb.txt)\r\nPlease rename test_nokogiri.rb.txt to test_nokogiri.rb\r\n\r\nor can copy & paste from below text for testing.\r\n\r\n**test_nokogiri.rb**\r\n```\r\nrequire 'rubygems'\r\nrequire 'nokogiri'\r\n\r\nputs Nokogiri::VERSION\r\n\r\nmodule Nokogiri\r\n  module HTML\r\n    class Document < Nokogiri::XML::Document\r\n      class << self\r\n        def test_for_parse\r\n\r\n          expect = <<'EOS'\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">\r\n<html><body>b</body></html>\r\nEOS\r\n\r\n          html = '<<a>b'\r\n          doc = read_memory(\"<html><body>#{html}\", nil, \"UTF-8\", 2145)\r\n          puts doc.to_s\r\n          p(doc.to_s == expect)\r\n        end\r\n      end\r\n    end\r\n  end\r\nend\r\n\r\nNokogiri::HTML::Document.test_for_parse\r\n```\r\n\r\n\r\n## Reproducing\r\n\r\nLet me report for detail.\r\n\r\nMy environment is as below things.\r\n```\r\n$ ruby -v\r\nruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]\r\n\r\n$ gcc --version\r\ngcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)\r\nCopyright (C) 2015 Free Software Foundation, Inc.\r\nThis is free software; see the source for copying conditions.  There is NO\r\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r\n```\r\n\r\n### Case1: nokogiri: v1.6.7.2 (with libxml2: 2.9.2)\r\n\r\n```\r\n$ git checkout v1.6.7.2\r\n\r\n$ bundle install --path vendor/bundle\r\n\r\n$ bundle exec rake test\r\n...\r\n1328 tests, 3051 assertions, 0 failures, 0 errors, 4 skips\r\n\r\n$ bundle exec ruby -Ilib bin/nokogiri -v\r\n# Nokogiri (1.6.7.2)\r\n    ---\r\n    warnings: []\r\n    nokogiri: 1.6.7.2\r\n    ruby:\r\n      version: 2.3.0\r\n      platform: x86_64-linux\r\n      description: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]\r\n      engine: ruby\r\n    libxml:\r\n      binding: extension\r\n      source: packaged\r\n      libxml2_path: \"/home/jaruga/git/nokogiri_v1.6.7.2/ports/x86_64-pc-linux-gnu/libxml2/2.9.2\"\r\n      libxslt_path: \"/home/jaruga/git/nokogiri_v1.6.7.2/ports/x86_64-pc-linux-gnu/libxslt/1.1.28\"\r\n      libxml2_patches:\r\n      - 0001-Revert-Missing-initialization-for-the-catalog-module.patch\r\n      - 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch\r\n      - 0003-Stop-parsing-on-entities-boundaries-errors.patch\r\n      - 0004-Cleanup-conditional-section-error-handling.patch\r\n      - 0005-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch\r\n      - 0006-Another-variation-of-overflow-in-Conditional-section.patch\r\n      - 0007-Fix-an-error-in-previous-Conditional-section-patch.patch\r\n      - 0008-CVE-2015-8035-Fix-XZ-compression-support-loop.patch\r\n      - 0009-Updated-config.guess.patch\r\n      - 0010-Fix-parsering-short-unclosed-comment-uninitialized-access.patch\r\n      - 0011-Avoid-extra-processing-of-MarkupDecl-when-EOF.patch\r\n      - 0012-Avoid-processing-entities-after-encoding-conversion-.patch\r\n      - 0013-CVE-2015-7497-Avoid-an-heap-buffer-overflow-in-xmlDi.patch\r\n      - 0014-CVE-2015-5312-Another-entity-expansion-issue.patch\r\n      - 0015-Add-xmlHaltParser-to-stop-the-parser.patch\r\n      - 0016-Detect-incoherency-on-GROW.patch\r\n      - 0017-CVE-2015-7500-Fix-memory-access-error-due-to-incorre.patch\r\n      - 0018-CVE-2015-8242-Buffer-overead-with-HTML-parser-in-pus.patch\r\n      - 0019-Do-not-print-error-context-when-there-is-none.patch\r\n      - 0020-xmlStopParser-reset-errNo.patch\r\n      - 0021-Reuse-xmlHaltParser-where-it-makes-sense.patch\r\n      libxslt_patches:\r\n      - 0001-Adding-doc-update-related-to-1.1.28.patch\r\n      - 0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch\r\n      - 0003-Initialize-pseudo-random-number-generator-with-curre.patch\r\n      - 0004-EXSLT-function-str-replace-is-broken-as-is.patch\r\n      - 0006-Fix-str-padding-to-work-with-UTF-8-strings.patch\r\n      - 0007-Separate-function-for-predicate-matching-in-patterns.patch\r\n      - 0008-Fix-direct-pattern-matching.patch\r\n      - 0009-Fix-certain-patterns-with-predicates.patch\r\n      - 0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch\r\n      - 0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch\r\n      - 0014-Fix-for-bug-436589.patch\r\n      - 0015-Fix-mkdir-for-mingw.patch\r\n      - 0016-Fix-for-type-confusion-in-preprocessing-attributes.patch\r\n      - 0017-Updated-config.guess.patch\r\n      compiled: 2.9.2\r\n      loaded: 2.9.2\r\n```\r\n\r\nCheck the result for read_memory testing script.\r\n```\r\n$ bundle exec ruby -Ilib test_nokogiri.rb\r\n1.6.7.2\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">\r\n<html><body>b</body></html>\r\ntrue\r\n```\r\n\r\n\r\n### Case2: nokogiri: lastest master (with libxml2: 2.9.3)\r\n\r\n```\r\n$ git checkout master\r\n\r\n$ git log --pretty=oneline | head -1\r\nfe57e9080a8f1c238c706f0599d5fcfaeea33f8c Merge pull request #1451 from ashivasubramanian/master\r\n\r\n$ bundle install --path vendor/bundle\r\n\r\n$ bundle exec rake test\r\n...\r\n1375 runs, 3936 assertions, 0 failures, 0 errors, 4 skips\r\n\r\n$ bundle exec ruby -Ilib bin/nokogiri -v\r\n# Nokogiri (1.6.8.rc3)\r\n    ---\r\n    warnings: []\r\n    nokogiri: 1.6.8.rc3\r\n    ruby:\r\n      version: 2.3.0\r\n      platform: x86_64-linux\r\n      description: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]\r\n      engine: ruby\r\n    libxml:\r\n      binding: extension\r\n      source: packaged\r\n      libxml2_path: \"/home/jaruga/git/nokogiri/ports/x86_64-pc-linux-gnu/libxml2/2.9.3\"\r\n      libxslt_path: \"/home/jaruga/git/nokogiri/ports/x86_64-pc-linux-gnu/libxslt/1.1.28\"\r\n      libxml2_patches: []\r\n      libxslt_patches:\r\n      - 0001-Adding-doc-update-related-to-1.1.28.patch\r\n      - 0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch\r\n      - 0003-Initialize-pseudo-random-number-generator-with-curre.patch\r\n      - 0004-EXSLT-function-str-replace-is-broken-as-is.patch\r\n      - 0006-Fix-str-padding-to-work-with-UTF-8-strings.patch\r\n      - 0007-Separate-function-for-predicate-matching-in-patterns.patch\r\n      - 0008-Fix-direct-pattern-matching.patch\r\n      - 0009-Fix-certain-patterns-with-predicates.patch\r\n      - 0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch\r\n      - 0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch\r\n      - 0014-Fix-for-bug-436589.patch\r\n      - 0015-Fix-mkdir-for-mingw.patch\r\n      - 0016-Fix-for-type-confusion-in-preprocessing-attributes.patch\r\n      - 0017-Updated-config.guess.patch\r\n      compiled: 2.9.3\r\n      loaded: 2.9.3\r\n```\r\n\r\nCheck the result for read_memory testing script.\r\n```\r\n$ bundle exec ruby -Ilib test_nokogiri.rb\r\n1.6.8.rc3\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">\r\n<html><body>&lt;<a>b</a>\r\n</body></html>\r\nfalse\r\n```\r\n=> The result is different!!\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/sparklemotion/nokogiri/issues/comments/219402946","html_url":"https://github.com/sparklemotion/nokogiri/issues/1465#issuecomment-219402946","issue_url":"https://api.github.com/repos/sparklemotion/nokogiri/issues/1465","id":219402946,"user":{"login":"junaruga","id":121989,"avatar_url":"https://avatars.githubusercontent.com/u/121989?v=3","gravatar_id":"","url":"https://api.github.com/users/junaruga","html_url":"https://github.com/junaruga","followers_url":"https://api.github.com/users/junaruga/followers","following_url":"https://api.github.com/users/junaruga/following{/other_user}","gists_url":"https://api.github.com/users/junaruga/gists{/gist_id}","starred_url":"https://api.github.com/users/junaruga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/junaruga/subscriptions","organizations_url":"https://api.github.com/users/junaruga/orgs","repos_url":"https://api.github.com/users/junaruga/repos","events_url":"https://api.github.com/users/junaruga/events{/privacy}","received_events_url":"https://api.github.com/users/junaruga/received_events","type":"User","site_admin":false},"created_at":"2016-05-16T11:18:02Z","updated_at":"2016-05-16T11:18:02Z","body":"Hi, @flavorjones \r\nThank you for your kind response.\r\n\r\nYes, your answer is great for me. I wanted to know whether it was bug for nokogiri or not. That means whether you are going to change nokogiri's code or not for that.\r\nBecause I am developing the RPM package for the gem package: \"sanitize\" [1] that is using \"nokogiri\". and the \"sanitize\" is affected by \"nokogiri\"'s this behavior.\r\n\r\nSo, now we could close this issue.\r\nThank you for your taking the time for me.\r\n\r\n[1] https://github.com/rgrove/sanitize\r\n"}}