-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[FIX] end tag with space after name should be valid #2899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gdcGithub
wants to merge
1
commit into
ajaxorg:master
Choose a base branch
from
gdcGithub:fixXmlEndTagSpace
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,7 +98,10 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){ | |
} | ||
switch(source.charAt(i+1)){ | ||
case '/': | ||
var end = source.indexOf('>',i+3); | ||
var regex = new RegExp("\\s*>"); | ||
var subSource = source.substr(i+2); | ||
var end = subSource.search(regex); | ||
end = end + i + 2; | ||
var tagName = source.substring(i+2,end); | ||
var config; | ||
if (parseStack.length > 1) { | ||
|
@@ -108,7 +111,7 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){ | |
break; | ||
} | ||
var localNSMap = config.localNSMap; | ||
|
||
if(config.tagName != tagName){ | ||
errorHandler.fatalError("end tag name: " + tagName + " does not match the current start tagName: "+config.tagName ); | ||
} | ||
|
@@ -132,9 +135,9 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){ | |
default: | ||
try{ | ||
locator&&position(i); | ||
|
||
var el = new ElementAttributes(); | ||
|
||
//elStartEnd | ||
var end = parseElementStartPart(source,i,el,entityReplacer,errorHandler); | ||
var len = el.length; | ||
|
@@ -155,8 +158,8 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){ | |
} | ||
} | ||
appendElement(el,domBuilder,parseStack); | ||
|
||
|
||
if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){ | ||
end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder) | ||
}else{ | ||
|
@@ -180,7 +183,7 @@ function copyLocator(f,t){ | |
t.lineNumber = f.lineNumber; | ||
t.columnNumber = f.columnNumber; | ||
return t; | ||
|
||
} | ||
|
||
/** | ||
|
@@ -368,7 +371,7 @@ function appendElement(el,domBuilder,parseStack){ | |
} | ||
//can not set prefix,because prefix !== '' | ||
a.localName = localName ; | ||
//prefix == null for no ns prefix attribute | ||
//prefix == null for no ns prefix attribute | ||
if(nsPrefix !== false){//hack!! | ||
if(localNSMap == null){ | ||
localNSMap = {} | ||
|
@@ -378,7 +381,7 @@ function appendElement(el,domBuilder,parseStack){ | |
} | ||
currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value; | ||
a.uri = 'http://www.w3.org/2000/xmlns/' | ||
domBuilder.startPrefixMapping(nsPrefix, value) | ||
domBuilder.startPrefixMapping(nsPrefix, value) | ||
} | ||
} | ||
var i = el.length; | ||
|
@@ -390,7 +393,7 @@ function appendElement(el,domBuilder,parseStack){ | |
a.uri = 'http://www.w3.org/XML/1998/namespace'; | ||
}if(prefix !== 'xmlns'){ | ||
a.uri = currentNSMap[prefix] | ||
|
||
//{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)} | ||
} | ||
} | ||
|
@@ -412,7 +415,7 @@ function appendElement(el,domBuilder,parseStack){ | |
domBuilder.endElement(ns,localName,tagName); | ||
if(localNSMap){ | ||
for(prefix in localNSMap){ | ||
domBuilder.endPrefixMapping(prefix) | ||
domBuilder.endPrefixMapping(prefix) | ||
} | ||
} | ||
}else{ | ||
|
@@ -438,7 +441,7 @@ function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBui | |
domBuilder.characters(text,0,text.length); | ||
return elEndStart; | ||
//} | ||
|
||
} | ||
} | ||
return elStartEnd+1; | ||
|
@@ -448,10 +451,17 @@ function fixSelfClosed(source,elStartEnd,tagName,closeMap){ | |
var pos = closeMap[tagName]; | ||
if(pos == null){ | ||
//console.log(tagName) | ||
pos = closeMap[tagName] = source.lastIndexOf('</'+tagName+'>') | ||
var regex = new RegExp("</"+tagName+"\\s*>", "gi"); | ||
var match = source.match(regex); | ||
if (match && match.length >= 1) { | ||
var lastIndex = source.lastIndexOf(match[match.length-1]); | ||
pos = closeMap[tagName] = lastIndex; | ||
} else { | ||
pos = -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also keep the same chain assignment from above here, so |
||
} | ||
} | ||
return pos<elStartEnd; | ||
//} | ||
//} | ||
} | ||
function _copy(source,target){ | ||
for(var n in source){target[n] = source[n]} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that doesn't seem the same.
So in case when I forget to close the tag:
end would be -1 because indexOf wouldn't find it
but in the new code end would be -1 + i + 2, so something else entirely.
Can we change this to something like:
end = endIndex === -1 ? endIndex: endIndex + i + 2
I am pretty sure it breaks something otherwise, because, this is the current error:

And this is the new one:
