Home Bug Reports

Cannot send strings with embedded \0

blairblair Member Blair ZajacOrganization: Sony Pictures ImageworksProject: VnP ✭✭
I accidentally got a \0 into a Java string used as an exception error message sent to the client and the any part of the string after the \0 does not appear on the client.

Using IcePy 3.2.0 for the client and server, you can reproduce this pretty easily:
interface Test
        idempotent string

Server side code:
class TestI(Test):
    def getString(self, current=None):
        s = 'hello '
        for i in range(3):
            s += chr(0)
        s += ' there'
        return s

Client side code:
s = self.VnpClock.getString()
        print repr(s)

I get the string 'hello '. If you change the chr(0) to a chr(1) then it works.

I was able to get the chr(0) into the Java server in the first place by passing from Python code to the Java server a string with a \0 in it.



  • Andreas SchererAndreas Scherer Member Andreas SchererOrganization: Private Linux SiteProject: Evaluating Ice-C++, Ice-Python, Ice-Ruby ✭✭
    Probably you are refering to the situation mentioned in section 4.8.3 of the Ice manual (page 91/109 of the 3.2.0 pdf):
    Slice strings use the Unicode character set. The only character that cannot appear inside a string is the zero character.

    Take care,
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    Andreas is correct, 0 is not allowed in Slice strings. See this footnote. However, it is a bug that Ice does not raise an exception. Thanks for reporting this, we will investigate and fix this.
  • blairblair Member Blair ZajacOrganization: Sony Pictures ImageworksProject: VnP ✭✭
    Thanks. It would be nice to get an exception on attempting to put a \0 into a string.

Sign In or Register to comment.