06.xhtml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. h t t :: / / t /
  4. h t t :: // // t //
  5. h ttttt ttttt ppppp sssss // // y y sssss ttttt //
  6. hhhh t t p p s // // y y s t //
  7. h hh t t ppppp sssss // // yyyyy sssss t //
  8. h h t t p s :: / / y .. s t .. /
  9. h h t t p sssss :: / / yyyyy .. sssss t .. /
  10. <https://y.st./>
  11. Copyright © 2016 Alex Yst <mailto:copyright@y.st>
  12. This program is free software: you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation, either version 3 of the License, or
  15. (at your option) any later version.
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. GNU General Public License for more details.
  20. You should have received a copy of the GNU General Public License
  21. along with this program. If not, see <https://www.gnu.org./licenses/>.
  22. -->
  23. <!DOCTYPE html>
  24. <html xmlns="http://www.w3.org/1999/xhtml">
  25. <head>
  26. <base href="https://y.st./en/weblog/2016/02-February/06.xhtml" />
  27. <title>The spider does not handle broken markup well &lt;https://y.st./en/weblog/2016/02-February/06.xhtml&gt;</title>
  28. <link rel="icon" type="image/png" href="/link/CC_BY-SA_4.0/y.st./icon.png" />
  29. <link rel="stylesheet" type="text/css" href="/link/basic.css" />
  30. <link rel="stylesheet" type="text/css" href="/link/site-specific.css" />
  31. <script type="text/javascript" src="/script/javascript.js" />
  32. <meta name="viewport" content="width=device-width" />
  33. </head>
  34. <body>
  35. <nav>
  36. <p>
  37. <a href="/en/">Home</a> |
  38. <a href="/en/a/about.xhtml">About</a> |
  39. <a href="/en/a/contact.xhtml">Contact</a> |
  40. <a href="/a/canary.txt">Canary</a> |
  41. <a href="/en/URI_research/"><abbr title="Uniform Resource Identifier">URI</abbr> research</a> |
  42. <a href="/en/opinion/">Opinions</a> |
  43. <a href="/en/coursework/">Coursework</a> |
  44. <a href="/en/law/">Law</a> |
  45. <a href="/en/a/links.xhtml">Links</a> |
  46. <a href="/en/weblog/2016/02-February/06.xhtml.asc">{this page}.asc</a>
  47. </p>
  48. <hr/>
  49. <p>
  50. Weblog index:
  51. <a href="/en/weblog/"><abbr title="American Standard Code for Information Interchange">ASCII</abbr> calendars</a> |
  52. <a href="/en/weblog/index_ol_ascending.xhtml">Ascending list</a> |
  53. <a href="/en/weblog/index_ol_descending.xhtml">Descending list</a>
  54. </p>
  55. <hr/>
  56. <p>
  57. Jump to entry:
  58. <a href="/en/weblog/2015/03-March/07.xhtml">&lt;&lt;First</a>
  59. <a rel="prev" href="/en/weblog/2016/02-February/05.xhtml">&lt;Previous</a>
  60. <a rel="next" href="/en/weblog/2016/02-February/07.xhtml">Next&gt;</a>
  61. <a href="/en/weblog/latest.xhtml">Latest&gt;&gt;</a>
  62. </p>
  63. <hr/>
  64. </nav>
  65. <header>
  66. <h1>The spider does not handle broken markup well</h1>
  67. <p>Day 00336: Saturday, 2016 February 06</p>
  68. </header>
  69. <p>
  70. I feel like I am stuck waiting for the time being.
  71. Until my appointment on Wednesday, in which I will learn what courses I would need to take to pursue finishing my associate degree at the local community college, I will not know whether I will be going back to school or attempting to find a full-time job for the time being.
  72. I cannot really make any plans until then.
  73. </p>
  74. <p>
  75. While the spider continues to run without error, I do not have any fatal bugs to work on, so it is time to work on feature support.
  76. The main two features on the waiting list are support for retrieving the full text of an <code>&lt;a/&gt;</code> tag even when it has child nodes and support for flat file databases.
  77. I think that it would be a lot of fun to try abstracting away the direct database calls, which would make supporting flat files and multiple database software options as easy as writing a new class, one that implements a particular interface, for each storage method desired.
  78. However, the <code>&lt;a/&gt;</code> tag issue is of more urgency, even if of less importance, so I set to work on that instead.
  79. </p>
  80. <p>
  81. Setting up that functionality turned out to be quite trivial.
  82. I set up a mock function that, if built, should provide exactly what I need to easily extract link text regardless of nesting.
  83. However, before I could build it, I ran some tests on some broken <abbr title="Extensible Markup Language">XML</abbr> to see how <abbr title="PHP: Hypertext Preprocessor">PHP</abbr>&apos;s <abbr title="Extensible Markup Language">XML</abbr> parser deals with broken <abbr title="Extensible Markup Language">XML</abbr>.
  84. As it turns out, it does not.
  85. As soon as an error is encountered, parsing stops.
  86. This is the proper behavior, but I had thought that I had tested the <abbr title="Extensible Markup Language">XML</abbr> parser on <abbr title="Hypertext Markup Language">HTML</abbr> (which is basically malformed <abbr title="Extensible Markup Language">XML</abbr> before.
  87. I had looked for some sort of error though, so when reasonable-looking data was returned, I must have assumed that it had not given up on the document.
  88. Partial data like this is probably worse than no data, as with partial data, I think that I have everything on the page parsed and do not realize that there is a bug in need of fixing.
  89. </p>
  90. <p>
  91. To be fair though, use of <abbr title="Hypertext Markup Language">HTML</abbr> and other broken markup is the real bug.
  92. But though the bug is not on my end, I need to be able to deal with it on my end.
  93. </p>
  94. <p>
  95. I added output to estimate the time remaining in the processing of a website, as it can be a bit bothersome waiting for the spider to be finished with a large website so that I can halt and restart it to see an update take effect.
  96. Next, I worked on improving my <abbr title="Uniform Resource Identifier">URI</abbr> handlers.
  97. In reality, a <abbr title="Uniform Resource Identifier">URI</abbr> is a specialized kind of data, so it would be better implemented as a class than as several functions like it was yesterday when I finished it.
  98. Additionally, as a class, it will only need to check the <abbr title="Uniform Resource Identifier">URI</abbr> components for validity during parsing, instead of both during parsing and during reconstruction.
  99. I think that I have the class working correctly, but I did not have time to test it tonight, so I will wait until tomorrow to upload it and integrate it with the spider.
  100. </p>
  101. <p>
  102. While combining the <abbr title="Uniform Resource Identifier">URI</abbr>-related functions into a class, I came across a corner case that I had not accounted for.
  103. <abbr title="Uniform Resource Identifier">URI</abbr>s such as <code>example:/.//</code> seem to be valid, though unnormalized.
  104. Using the standard normalization method though, the path becomes <code>///</code>.
  105. With no host component present, the path cannot begin with two slashes.
  106. However, normalizing the path is not allowed to alter the host component, so we cannot normalize the <abbr title="Uniform Resource Identifier">URI</abbr> to <code>example:///</code> and say that the new path is <code>/</code>.
  107. I have no idea how to properly normalize this <abbr title="Uniform Resource Identifier">URI</abbr>.
  108. For the time being, I set up a loop that is entered when this type of situation is encountered.
  109. As long as the first two characters of the path are both slashes, one will be removed and the loop will continue.
  110. I am not sure that this is the correct way to handle this situation, but it is a better idea than any of the alternatives I came up with, such as encoding one of the slashes as <code>%25</code> or prefixing the path with some character do that the path did not start with a slash at all.
  111. </p>
  112. <p>
  113. I spent most of the day running errands in Springfield with my mother.
  114. It seems that my presence was not really needed though and I was not able to help.
  115. </p>
  116. <hr/>
  117. <p>
  118. Copyright © 2016 Alex Yst;
  119. You may modify and/or redistribute this document under the terms of the <a rel="license" href="/license/gpl-3.0-standalone.xhtml"><abbr title="GNU&apos;s Not Unix">GNU</abbr> <abbr title="General Public License version Three or later">GPLv3+</abbr></a>.
  120. If for some reason you would prefer to modify and/or distribute this document under other free copyleft terms, please ask me via email.
  121. My address is in the source comments near the top of this document.
  122. This license also applies to embedded content such as images.
  123. For more information on that, see <a href="/en/a/licensing.xhtml">licensing</a>.
  124. </p>
  125. <p>
  126. <abbr title="World Wide Web Consortium">W3C</abbr> standards are important.
  127. This document conforms to the <a href="https://validator.w3.org./nu/?doc=https%3A%2F%2Fy.st.%2Fen%2Fweblog%2F2016%2F02-February%2F06.xhtml"><abbr title="Extensible Hypertext Markup Language">XHTML</abbr> 5.1</a> specification and uses style sheets that conform to the <a href="http://jigsaw.w3.org./css-validator/validator?uri=https%3A%2F%2Fy.st.%2Fen%2Fweblog%2F2016%2F02-February%2F06.xhtml"><abbr title="Cascading Style Sheets">CSS</abbr>3</a> specification.
  128. </p>
  129. </body>
  130. </html>