Handle a CDATA section.
500023
protected function cdataSection() {
        if ($this->scanner->current() != '[') {
            return false;
        }
        $cdata = '';
        $this->scanner->next();

        $chars = $this->scanner->charsWhile('CDAT');
        if ($chars != 'CDATA' || $this->scanner->current() != '[') {
            $this->parseError('Expected [CDATA[, got %s', $chars);
            return $this->bogusComment('<![' . $chars);
        }

        $tok = $this->scanner->next();
        do {
            if ($tok === false) {
                $this->parseError('Unexpected EOF inside CDATA.');
                $this->bogusComment('<![CDATA[' . $cdata);
                return true;
            }
            $cdata .= $tok;
            $tok = $this->scanner->next();
        } while (!$this->sequenceMatches(']]>'));

        // Consume ]]>
        $this->scanner->consume(3);

        $this->events->cdata($cdata);
        return true;
    }
875303
def handle_data(self, data):
        
        if self.current_parent_element['tag'] == '':
            self.cleaned_html += '<p>'
            self.current_parent_element['tag'] = 'p'

        self.cleaned_html += data
4012
public static StringBuffer appendCdataSection(StringBuffer buffer, String cdataContent)
	{
		StringBuffer _buffer = initStringBufferIfNecessary(buffer);
		return doAppendCdataSection(_buffer, cdataContent);
	}
1116186
protected void compareCDataSection(CDATASection control, CDATASection test,
                                       DifferenceListener listener) throws DifferenceFoundException {
        compareText(control, test, listener);
    }
36634
public function addCData($name, $cdata)
    {
        $nameUtf8 = $this->_toUTF8($name);
        $node = $this->_SimpleXmlElement->addChild($nameUtf8);
        $domnode = dom_import_simplexml($node);
        $no = $domnode->ownerDocument;
        $domnode->appendChild($no->createCDATASection($cdata));

        return new SimpleXMLExtended($node, $this->_encoding);
    }
959677
def _parseSections(self, data, imageDosHeader, imageNtHeaders, parse_header_only=False):
        """"""
        sections = []

        optional_header_offset = imageDosHeader.header.e_lfanew + 4 + sizeof(IMAGE_FILE_HEADER)
        offset = optional_header_offset + imageNtHeaders.header.FileHeader.SizeOfOptionalHeader  # start reading behind the dos- and ntheaders

        image_section_header_size = sizeof(IMAGE_SECTION_HEADER)

        for sectionNo in range(imageNtHeaders.header.FileHeader.NumberOfSections):
            ishdr = IMAGE_SECTION_HEADER.from_buffer(data, offset)

            if parse_header_only:
                raw = None
                bytes_ = bytearray()
            else:
                size = ishdr.SizeOfRawData
                raw = (c_ubyte * size).from_buffer(data, ishdr.PointerToRawData)
                bytes_ = bytearray(raw)

            sections.append(SectionData(header=ishdr, name=ishdr.Name.decode('ASCII', errors='ignore'), bytes=bytes_, raw=raw))

            offset += image_section_header_size

        return sections
944633
def _fill_cdata(cls):
    """"""

    funcs = {}
    for key, name in [("b", "char"), ("h", "short"),
                      ("i", "int"), ("q", "longlong")]:
        for echar, esuffix in [("<", "le"), (">", "be")]:
            esuffix = "_" + esuffix
            for unsigned in [True, False]:
                s = struct.Struct(echar + (key.upper() if unsigned else key))
                get_wrapper = lambda f: lambda *a, **k: f(*a, **k)[0]
                unpack = get_wrapper(s.unpack)
                unpack_from = get_wrapper(s.unpack_from)

                def get_unpack_from(s):
                    def unpack_from(data, offset=0):
                        return s.unpack_from(data, offset)[0], offset + s.size
                    return unpack_from

                unpack_from = get_unpack_from(s)
                pack = s.pack

                prefix = "u" if unsigned else ""
                if s.size == 1:
                    esuffix = ""
                bits = str(s.size * 8)

                if unsigned:
                    max_ = 2 ** (s.size * 8) - 1
                    min_ = 0
                else:
                    max_ = 2 ** (s.size * 8 - 1) - 1
                    min_ = - 2 ** (s.size * 8 - 1)

                funcs["%s%s_min" % (prefix, name)] = min_
                funcs["%s%s_max" % (prefix, name)] = max_
                funcs["%sint%s_min" % (prefix, bits)] = min_
                funcs["%sint%s_max" % (prefix, bits)] = max_

                funcs["%s%s%s" % (prefix, name, esuffix)] = unpack
                funcs["%sint%s%s" % (prefix, bits, esuffix)] = unpack
                funcs["%s%s%s_from" % (prefix, name, esuffix)] = unpack_from
                funcs["%sint%s%s_from" % (prefix, bits, esuffix)] = unpack_from
                funcs["to_%s%s%s" % (prefix, name, esuffix)] = pack
                funcs["to_%sint%s%s" % (prefix, bits, esuffix)] = pack

    for key, func in iteritems(funcs):
        setattr(cls, key, staticmethod(func))
840723
def get_section_data(self, name):
        """"""
        logging.debug(_('Obtaining PE section: %s'), name)
        for section in self.binary.sections:
            if section.Name.rstrip(b'\x00') == name:
                return section.get_data()
        return b''
993906
def _cdata_io(self, action, data, ctype, frames):
        """"""
        assert ctype in _ffi_types.values()
        self._check_if_closed()
        if self.seekable():
            curr = self.tell()
        func = getattr(_snd, 'sf_' + action + 'f_' + ctype)
        frames = func(self._file, data, frames)
        _error_check(self._errorcode)
        if self.seekable():
            self.seek(curr + frames, SEEK_SET)  # Update read & write position
        return frames
1041570
def Handle(self, unused_args, token=None):
    """"""

    sections = {}
    for descriptor in config.CONFIG.type_infos:
      if descriptor.section in sections:
        continue

      section_data = {}
      for parameter in self._ListParametersInSection(descriptor.section):
        section_data[parameter] = ApiConfigOption().InitFromConfigOption(
            parameter)

      sections[descriptor.section] = section_data

    result = ApiGetConfigResult()
    for section_name in sorted(sections):
      section = sections[section_name]

      api_section = ApiConfigSection(name=section_name)
      api_section.options = []
      for param_name in sorted(section):
        api_section.options.append(section[param_name])
      result.sections.append(api_section)

    return result
474657
def _handle_content(self, relpath, params):
    """"""
    abspath = os.path.normpath(os.path.join(self._root, relpath))
    if os.path.isfile(abspath):
      with open(abspath, 'rb') as infile:
        content = infile.read()
    else:
      content = 'No file found at {}'.format(abspath).encode('utf-8')
    content_type = mimetypes.guess_type(abspath)[0] or 'text/plain'
    if not content_type.startswith('text/') and not content_type == 'application/xml':
      # Binary file. Display it as hex, split into lines.
      n = 120  # Display lines of this max size.
      content = repr(content)[1:-1]  # Will escape non-printables etc, dropping surrounding quotes.
      content = '\n'.join([content[i:i + n] for i in range(0, len(content), n)])
      prettify = False
      prettify_extra_langs = []
    else:
      prettify = True
      if self._settings.assets_dir:
        prettify_extra_dir = os.path.join(self._settings.assets_dir, 'js', 'prettify_extra_langs')
        prettify_extra_langs = [{'name': x} for x in os.listdir(prettify_extra_dir)]
      else:
        # TODO: Find these from our package, somehow.
        prettify_extra_langs = []
    linenums = True
    args = {'prettify_extra_langs': prettify_extra_langs, 'content': content,
            'prettify': prettify, 'linenums': linenums}
    content = self._renderer.render_name('file_content.html', args).encode("utf-8")
    self._send_content(content, 'text/html')
1291300
def handle_data(self, data):
        """"""
        if not self.silent:
            possible_urls = re.findall(
                r'(https?://[\w\d:#%/;$()~_?\-=\\\.&]*)', data)
            # validate possible urls
            # we'll transform them just in case
            # they are valid.
            if possible_urls and self.automatic_link_transformation:
                for url in possible_urls:
                    if regex_url.search(url):
                        transformed_url = '<a href="%s">%s</a>' % (url, url)
                        data = data.replace(url, transformed_url)
                self.result += data
            else:
                self.result += cgi.escape(data, True)
1034910
@Override
    public int writeCData(String data) throws IOException
    {
        writeAscii("<![CDATA[");
        int ix = writeCDataContent(data);
        if (ix >= 0) {
            return ix;
        }
        writeAscii("]]>");
        return -1;
    }
453384
public function cdata($cdata) {
		if (null === $this->currentTagName) return;
		switch ($this->currentTagName) {
			case AdminMailCenter::TAG_NAME_MESSAGE:
				$this->currentItem->setMessage($cdata);
				break;
			case AdminMailCenter::TAG_NAME_SUBJECT:
				$this->currentItem->setSubject($cdata);
				break;
			case AdminMailCenter::TAG_NAME_TO:
				$this->currentItem->setTo($cdata);
				break;
			case AdminMailCenter::TAG_NAME_FROM:
				$this->currentItem->setFrom($cdata);
				break;
			case AdminMailCenter::TAG_NAME_CC:
				$this->currentItem->setCc($cdata);
				break;
			case AdminMailCenter::TAG_NAME_BCC:
				$this->currentItem->setBcc($cdata);
				break;
			case AdminMailCenter::TAG_NAME_REPLY_TO:
				$this->currentItem->setReplyTo($cdata);
				break;
			case AdminMailCenter::TAG_NAME_NAME:
				$cdata = preg_replace('/\s/', '', $cdata);
				$this->currentAttachmentItem->setName($cdata);
				break;
			case AdminMailCenter::TAG_NAME_PATH:
				$cdata = preg_replace('/\s/', '', $cdata);
				$this->currentAttachmentItem->setPath($cdata);
				break;
		}
	}
1064937
public function addChildCData($name, $cdata_text)
    {
        $child = $this->addChild($name);
        $child->addCData($cdata_text);
    }
82861
private void setDefaultParseSettings() {
        if (!parseSettings.containsKey(CDATA_SECTIONS)) {
            parseSettings.put(CDATA_SECTIONS, true);
        }

        if (!parseSettings.containsKey(SPLIT_CDATA_SECTIONS)) {
            parseSettings.put(SPLIT_CDATA_SECTIONS, false);
        }

        if (!parseSettings.containsKey(VALIDATE_IF_SCHEMA)) {
            parseSettings.put(VALIDATE_IF_SCHEMA, true);
        }

        if (!parseSettings.containsKey(RESOURCE_RESOLVER)) {
            parseSettings.put(RESOURCE_RESOLVER, createLSResourceResolver());
        }

        if (!parseSettings.containsKey(ELEMENT_CONTENT_WHITESPACE)) {
            parseSettings.put(ELEMENT_CONTENT_WHITESPACE, false);
        }
    }
1165019
@Override
    public void handleCDATASection(
            final char[] buffer,
            final int contentOffset, final int contentLen, final int outerOffset,
            final int outerLen, final int line, final int col)
            throws ParseException {

        if (!this.insideAllSelectorMatchingBlock) {

            this.someSelectorsMatch = false;
            for (int i = 0; i < this.selectorsLen; i++) {

                if (this.matchingMarkupLevelsPerSelector[i] > this.markupLevel) {
                    this.selectorMatches[i] =
                            this.selectorFilters[i].matchCDATASection(true, this.markupLevel, this.markupBlocks[this.markupLevel]);
                    if (this.selectorMatches[i]) {
                        this.someSelectorsMatch = true;
                    }
                } else {
                    this.selectorMatches[i] = true;
                    this.someSelectorsMatch = true;
                }

            }

            if (this.someSelectorsMatch) {
                markCurrentSelection();
                this.selectedHandler.handleCDATASection(
                        buffer, contentOffset, contentLen,
                        outerOffset, outerLen, line, col);
                unmarkCurrentSelection();
                return;
            }

            unmarkCurrentSelection();
            this.nonSelectedHandler.handleCDATASection(
                    buffer, contentOffset, contentLen,
                    outerOffset, outerLen, line, col);
            return;

        }

        markCurrentSelection();
        this.selectedHandler.handleCDATASection(buffer, contentOffset, contentLen, outerOffset, outerLen, line, col);
        unmarkCurrentSelection();

    }