Closed Bug 481822 Opened 17 years ago Closed 17 years ago

Empty XHTML span tag is interpreted as an opening tag

Categories

(Firefox :: General, defect)

x86
Windows NT
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: sfl, Unassigned)

Details

Attachments

(7 files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 I found out with Firebug that empty XHTML span tags <span /> in an XHTML file are incorrectly interpreted, i.e. not like empty HTML span tags <span></span>. I'm using empty span tags to fix a bug in Lotus Notes 6.5.4 & 7.0 and it's quite important to me (I'm working for an email-marketing company). Empty XHTML span tags are interpreted as opening tags and firefox is adding a closing tag as if it were missing (the closing tag is added after the following siblings). Reproducible: Always Steps to Reproduce: 1. Open this XHTML code in firefox: <?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type" /><title>Bug with empty XHTML span tag</title></head><body><span></span><b>Text after an empty HTML span tag</b><br /><span /><b>Text after an empty XHTML span tag</b><br /></body></html> 2. Explore the code with Firebug. Actual Results: I get following code: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> <title>Bug with empty XHTML span tag</title> </head> <body> <span/> <b>Text after an empty HTML span tag</b> <br/> <span> <b>Text after an empty XHTML span tag</b> <br/> </span> </body> </html> Expected Results: I expected to get that: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> <title>Bug with empty XHTML span tag</title> </head> <body> <span/> <b>Text after an empty HTML span tag</b> <br/> <span/> <b>Text after an empty XHTML span tag</b> <br/> </body> </html> I'm using Firebug 1.3.3 but it isn't a bug in Firebug: http://code.google.com/p/fbug/issues/detail?id=1550
Can you attach it instead of pasting into the text? And when you do, make sure it's xhtml - definitely remove that content="text/html" part because that makes it html.
I get the same bug in all cases.
They're all html. Click on attachment's details and change the mime type field to appropriate content type (just "application/xhtml+xml" example would be fine).
Attachment #365837 - Attachment mime type: text/html → application/xhtml+xml
Attachment #365839 - Attachment mime type: text/html → application/xml
Attachment #365838 - Attachment mime type: text/html → text/xml
OK - So Firefox is using a wrong mime type when I open local files?
I don't know actually. I'm quite sure it's using file extension (needs to be .xhtml for xml files) - but I don't know if <meta> does anything when extension is present. You can always check what mime-type is being used by using 'view page info'.
Attached image Page info
Well, the meta tag is actually being ignored if the file has an extension. And if it hasn't got any extension, the source code is being displayed as if it were a text file...
Do you think it should be reported as a bug? Firefox does o.g. correctly recognize the type of an image file with the wrong extension. It would be good that a file with an <?xml ?> header be recognized as XML file and that the meta tag of a file with XHTML content be used as mime type... What do you think?
Not sure, you might want to file a new bug (or search if it's not filed) and close this one. But I think there's a fundamental problem with such approach: to actually read the <meta> tag mozilla needs either html parser or xml parser. So what would happen here is that one parser is used, <meta> is read, and document is read again -- and possibly might now encounter a different <meta> tag (one valid in html and another valid in xml, this can be done)... a mess. Also, there's many files on the web which use xml declarations but are in fact html files (sent with text/html mime type). If they're saved to disk, and then opened, they shouldn't suddenly be considered xml (they probably won't work). So... feel free to file it if you think it's important despite such traps.
I'm using IE 7 (Version 6.0.2900.5512 with SP3) and I can't open a local XHTML file with an .xhtml extension... Bug I can open the same file with an .html extension. So I wouldn't like to rename my XHTML files - Windows users using IE couldn't open them. And fixing Firefox would go faster as making IE parse XHTML correctly...
Always the same mess with IE & FF... :-(
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → WONTFIX
IE does not even have an xml parser, it doesn't support xhtml at all and never did. This is why xhtml is never used on the web (xml declarations in files which are otherwise text/html don't count, they just make broken html files). Anyway, such discussion is not a bugzilla material - you should probably close this bug as "resolved worksforme" since your "expected results" do happen if xhtml is a real xhtml file - which is rare, yes.
Resolution: WONTFIX → WORKSFORME
OK, so I can use XHTML <br /> and <img /> tags because they don't have closing tags in HTML, but I can't use XHTML <span /> tags because a closing </span> tag would be added by the HTML parser (in FF with the wrong mime type and in IE too). So I've got a workaround and that's all I needed... Thank you very much for your support!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: