MCPcopy Create free account
hub / github.com/ampproject/amphtml / parseText

Function parseText

third_party/caja/html-sanitizer.js:1973–2000  ·  view source on GitHub ↗
(parts, tag, h, param, continuationMarker, state)

Source from the content-addressed store, hash-verified

1971 // Tags like <script> and <textarea> are flagged as CDATA or RCDATA,
1972 // which means everything is text until we see the correct closing tag.
1973 function parseText(parts, tag, h, param, continuationMarker, state) {
1974 var end = parts.length;
1975 if (!endTagRe.hasOwnProperty(tag.name)) {
1976 endTagRe[tag.name] = new RegExp('^' + tag.name + '(?:[\\s\\/]|$)', 'i');
1977 }
1978 var re = endTagRe[tag.name];
1979 var first = tag.next;
1980 var p = tag.next + 1;
1981 for (; p < end; p++) {
1982 if (parts[p - 1] === '<\/' && re.test(parts[p])) { break; }
1983 }
1984 if (p < end) { p -= 1; }
1985 var buf = parts.slice(first, p).join('');
1986 if (tag.eflags & html4.eflags['CDATA']) {
1987 if (h.cdata) {
1988 h.cdata(buf, param, continuationMarker,
1989 continuationMaker(h, parts, p, state, param));
1990 }
1991 } else if (tag.eflags & html4.eflags['RCDATA']) {
1992 if (h.rcdata) {
1993 h.rcdata(normalizeRCData(buf), param, continuationMarker,
1994 continuationMaker(h, parts, p, state, param));
1995 }
1996 } else {
1997 throw new Error('bug');
1998 }
1999 return p;
2000 }
2001
2002 // at this point, parts[pos-1] is either "<" or "<\/".
2003 function parseTagAndAttrs(parts, pos) {

Callers 2

parseCPSFunction · 0.85
parseStartTagFunction · 0.85

Calls 5

continuationMakerFunction · 0.85
normalizeRCDataFunction · 0.85
testMethod · 0.45
cdataMethod · 0.45
rcdataMethod · 0.45

Tested by

no test coverage detected