[Cuis-dev] printString on String
Jon Raiford
raiford at labware.com
Thu Dec 12 04:22:59 PST 2024
To expand on my response a little… Unless it is reimplemented, #printString ultimately sends #printOn: to the object. This is the reason the quotes end up around strings in Workspaces when you “print It” on a string object. So by calling printString and printing the result, you are asking it to printOn: twice.
Jon
From: Cuis-dev <cuis-dev-bounces at lists.cuis.st> on behalf of Jon Raiford via Cuis-dev <cuis-dev at lists.cuis.st>
Date: Thursday, December 12, 2024 at 7:10 AM
To: Discussion of Cuis Smalltalk <cuis-dev at lists.cuis.st>
Cc: Jon Raiford <raiford at labware.com>
Subject: Re: [Cuis-dev] printString on String
Yes, printString answers the string enclosed in single quotes and it even doubles up any single quotes inside the string. This is especially useful when building database queries to prevent sql injection attacks.
Jon
From: Cuis-dev <cuis-dev-bounces at lists.cuis.st> on behalf of Hilaire Fernandes via Cuis-dev <cuis-dev at lists.cuis.st>
Date: Thursday, December 12, 2024 at 5:53 AM
To: Discussion of Cuis Smalltalk <cuis-dev at lists.cuis.st>
Cc: Hilaire Fernandes <hfern at free.fr>
Subject: [Cuis-dev] printString on String
Hi,
Is it the expected behavior to have quoted included when asking printString to a String ?
'Toto' printString
=> '''Toto''' .
Using #asString solves this issue but not exactly the same semantic
--
http://mamot.fr/@drgeo<http://mamot.fr/@drgeo>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20241212/8d4f0ab8/attachment-0001.htm>
More information about the Cuis-dev
mailing list