Changeset b6f0405 in github
- Timestamp:
- May 27, 2010 9:34:58 AM (3 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- e559232
- Parents:
- a3c9bd1
- File:
-
- 1 edited
-
program/lib/washtml.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/lib/washtml.php
r0b7f3a8 rb6f0405 75 75 * - changed $ignore_elements behaviour 76 76 * - added RFC2397 support 77 * - base URL support 77 78 */ 78 79 … … 145 146 ')\s*/i', $str, $match)) { 146 147 if ($match[2]) { 147 if ($src = $this->config['cid_map'][$match[2]]) 148 if (($src = $this->config['cid_map'][$match[2]]) 149 || ($src = $this->config['cid_map'][$this->config['base_url'].$match[2]])) { 148 150 $value .= ' url('.htmlspecialchars($src, ENT_QUOTES) . ')'; 151 } 149 152 else if (preg_match('/^(http|https|ftp):.*$/i', $match[2], $url)) { 150 153 if ($this->config['allow_remote']) … … 181 184 $t .= ' style="' . $style . '"'; 182 185 else if ($key == 'background' || ($key == 'src' && strtolower($node->tagName) == 'img')) { //check tagName anyway 183 if ($src = $this->config['cid_map'][$value]) { 186 if (($src = $this->config['cid_map'][$value]) 187 || ($src = $this->config['cid_map'][$this->config['base_url'].$value])) { 184 188 $t .= ' ' . $key . '="' . htmlspecialchars($src, ENT_QUOTES) . '"'; 185 189 } … … 216 220 case XML_ELEMENT_NODE: //Check element 217 221 $tagName = strtolower($node->tagName); 218 if ($callback = $this->handlers[$tagName]) {222 if ($callback = $this->handlers[$tagName]) { 219 223 $dump .= call_user_func($callback, $tagName, $this->wash_attribs($node), $this->dumpHtml($node)); 220 } else if(isset($this->_html_elements[$tagName])) { 224 } 225 else if (isset($this->_html_elements[$tagName])) { 221 226 $content = $this->dumpHtml($node); 222 227 $dump .= '<' . $tagName . $this->wash_attribs($node) . 223 228 ($content != '' || isset($this->_block_elements[$tagName]) ? ">$content</$tagName>" : ' />'); 224 } else if(isset($this->_ignore_elements[$tagName])) { 229 } 230 else if (isset($this->_ignore_elements[$tagName])) { 225 231 $dump .= '<!-- ' . htmlspecialchars($tagName, ENT_QUOTES) . ' not allowed -->'; 226 } else { 232 } 233 else { 227 234 $dump .= '<!-- ' . htmlspecialchars($tagName, ENT_QUOTES) . ' ignored -->'; 228 235 $dump .= $this->dumpHtml($node); // ignore tags not its content 229 }236 } 230 237 break; 231 238 case XML_CDATA_SECTION_NODE: … … 250 257 /* Main function, give it untrusted HTML, tell it if you allow loading 251 258 * remote images and give it a map to convert "cid:" urls. */ 252 public function wash($html) { 253 //Charset seems to be ignored (probably if defined in the HTML document) 259 public function wash($html) 260 { 261 // Charset seems to be ignored (probably if defined in the HTML document) 254 262 $node = new DOMDocument('1.0', $this->config['charset']); 255 263 $this->extlinks = false; 264 265 // Find base URL for images 266 if (preg_match('/<base\s+href=[\'"]*([^\'"]+)/is', $html, $matches)) 267 $this->config['base_url'] = $matches[1]; 268 else 269 $this->config['base_url'] = ''; 270 256 271 @$node->loadHTML($html); 257 272 return $this->dumpHtml($node);
Note: See TracChangeset
for help on using the changeset viewer.
