Closed benny-innofaith closed 6 years ago
The problem manifest itself when reading a HTML file and outputting it again to a HTML string.
<!DOCTYPE html> <head> <title>debug</title> </head> <body> <svg id="draw_area" width="600" height="800" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"> <image id="overlay_img" xlink:href="foo.png" x="0" y="0" width="600" height="800" /> </svg> </body> </html>
NSString *dpath = [[NSBundle mainBundle] pathForResource:@"debug" ofType:@"html"]; NSString *dcontent = [NSString stringWithContentsOfFile:dpath encoding:NSUTF8StringEncoding error:nil]; HTMLDocument* ddocument = [HTMLDocument documentWithString:dcontent]; dcontent = [[ddocument documentElement] innerHTML];
After above code the variable dcontent contains:
dcontent
<head> <title>debug</title> </head> <body> <svg id="draw_area" width="600" height="800" xmlns="http://www.w3.org/2000/svg" xmlns xlink="http://www.w3.org/1999/xlink" version="1.1"> <image id="overlay_img" xlink href="foo.png" x="0" y="0" width="600" height="800"></image> </svg> </body>
Note how xmlns:xlink is converted to xmlns xlink and xlink:href to xlink href after outputting the content to HTML again. This broke the svg.
xmlns:xlink
xmlns xlink
xlink:href
xlink href
Can this code be released?
@benny-innofaith Done. Sorry for forgetting this. It just slipped my mind.
The problem manifest itself when reading a HTML file and outputting it again to a HTML string.
debug.html
After above code the variable
dcontent
contains:Note how
xmlns:xlink
is converted toxmlns xlink
andxlink:href
toxlink href
after outputting the content to HTML again. This broke the svg.