[FogBugz #521] Compression oracle #584

Open
opened 2023-07-04 08:46:35 +02:00 by fbenoist68 · 7 comments

Assigned To: Frederik Benoist
Project: Mobile Portal
Area: Divers
Category: Article Programme
Priority: A faire si temps disponible

Assigned To: Frederik Benoist Project: Mobile Portal Area: Divers Category: Article Programme Priority: A faire si temps disponible
Poster
Owner

Event ID: 2381
Date: 2016-10-25T05:58:32Z
Person: Frederik Benoist
Description: Modifié par Frederik Benoist

// permettra de rendre le texte lisible en JSON
inputStream in = IOUtils.toInputStream(StringEscapeUtils.escapeHtml(ptext)); // ,"UTF8")

Event ID: 2381 Date: 2016-10-25T05:58:32Z Person: Frederik Benoist Description: Modifié par Frederik Benoist <p>// permettra de rendre le texte lisible en JSON<br /> <code>inputStream in = IOUtils.toInputStream(StringEscapeUtils.escapeHtml(ptext)); // ,&quot;UTF8&quot;)</code></p>
Poster
Owner

Event ID: 2380
Date: 2016-10-25T05:48:30Z
Person: Frederik Benoist
Description: Modifié par Frederik Benoist

org.json.simple.JSONObject.escape() escapes quotes,\, /, \r, \n, \b, \f, \t and other control characters. It can be used to escape JavaScript codes.

import org.json.simple.JSONObject;
String test =  JSONObject.escape("your string");

 

Event ID: 2380 Date: 2016-10-25T05:48:30Z Person: Frederik Benoist Description: Modifié par Frederik Benoist <p>org.json.simple.JSONObject.escape() escapes quotes,\, /, \r, \n, \b, \f, \t and other control characters. It can be used to escape JavaScript codes.</p> <p>i<code>mport org.json.simple.JSONObject;<br /> String test =&nbsp; JSONObject.escape(&quot;your string&quot;);</code></p> <p>&nbsp;</p>
Poster
Owner

Event ID: 2379
Date: 2016-10-25T05:21:01Z
Person: Frederik Benoist
Description: Modifié par Frederik Benoist

Event ID: 2379 Date: 2016-10-25T05:21:01Z Person: Frederik Benoist Description: Modifié par Frederik Benoist
Poster
Owner

Event ID: 2378
Date: 2016-10-25T05:20:43Z
Person: Frederik Benoist
Description: Modifié par Frederik Benoist

On peut utiliser aussi le base64 :

 

s3Config.policy = new Buffer(JSON.stringify(s3Config.policy)).toString('base64');
Event ID: 2378 Date: 2016-10-25T05:20:43Z Person: Frederik Benoist Description: Modifié par Frederik Benoist <p>On peut utiliser aussi le base64 :</p> <p>&nbsp;</p> <pre> <code>s3Config.policy = new Buffer(JSON.stringify(s3Config.policy)).toString(&#39;base64&#39;); </code></pre>
Poster
Owner

Event ID: 2377
Date: 2016-10-25T04:47:27Z
Person: Frederik Benoist
Description: Modifié par Frederik Benoist

SET SERVEROUTPUT ON

DECLARE

l_in_blob            BLOB;

l_compressed_blob    BLOB;

l_uncompressed_blob  BLOB;

BEGIN

-- Set some values

l_in_blob     := TO_BLOB(UTL_RAW.CAST_TO_RAW

('This is a long string of words used for this example'));

l_compressed_blob   := TO_BLOB('0');

l_uncompressed_blob := TO_BLOB('0');


-- Compress the string

UTL_COMPRESS.lz_compress

(src => l_in_blob, dst => l_compressed_blob);


-- Uncompress the string

UTL_COMPRESS.lz_uncompress

(src => l_compressed_blob, dst => l_uncompressed_blob);


-- Compare the results with the input

DBMS_OUTPUT.put_line('Input length is    : ' || LENGTH(l_in_blob));

DBMS_OUTPUT.put_line('Compressed length  : ' || LENGTH(l_compressed_blob));

DBMS_OUTPUT.put_line('Uncompressed length: ' || LENGTH(l_uncompressed_blob));


-- Caller responsibility to free up temporary LOBs

-- See Operational Notes in the documentation

DBMS_LOB.FREETEMPORARY(l_in_blob);

DBMS_LOB.FREETEMPORARY(l_compressed_blob);

DBMS_LOB.FREETEMPORARY(l_uncompressed_blob);

END;

/
Event ID: 2377 Date: 2016-10-25T04:47:27Z Person: Frederik Benoist Description: Modifié par Frederik Benoist <pre> SET SERVEROUTPUT ON DECLARE l_in_blob BLOB; l_compressed_blob BLOB; l_uncompressed_blob BLOB; BEGIN -- Set some values l_in_blob := TO_BLOB(UTL_RAW.CAST_TO_RAW (&#39;This is a long string of words used for this example&#39;)); l_compressed_blob := TO_BLOB(&#39;0&#39;); l_uncompressed_blob := TO_BLOB(&#39;0&#39;); -- Compress the string UTL_COMPRESS.lz_compress (src =&gt; l_in_blob, dst =&gt; l_compressed_blob); -- Uncompress the string UTL_COMPRESS.lz_uncompress (src =&gt; l_compressed_blob, dst =&gt; l_uncompressed_blob); -- Compare the results with the input DBMS_OUTPUT.put_line(&#39;Input length is : &#39; || LENGTH(l_in_blob)); DBMS_OUTPUT.put_line(&#39;Compressed length : &#39; || LENGTH(l_compressed_blob)); DBMS_OUTPUT.put_line(&#39;Uncompressed length: &#39; || LENGTH(l_uncompressed_blob)); -- Caller responsibility to free up temporary LOBs -- See Operational Notes in the documentation DBMS_LOB.FREETEMPORARY(l_in_blob); DBMS_LOB.FREETEMPORARY(l_compressed_blob); DBMS_LOB.FREETEMPORARY(l_uncompressed_blob); END; /</pre>
Poster
Owner

Event ID: 2376
Date: 2016-10-25T04:46:39Z
Person: Frederik Benoist
Description: Attribué à Frederik Benoist par Frederik Benoist

Event ID: 2376 Date: 2016-10-25T04:46:39Z Person: Frederik Benoist Description: Attribué à Frederik Benoist par Frederik Benoist
Poster
Owner

Event ID: 2375
Date: 2016-10-25T04:46:39Z
Person: Frederik Benoist
Description: Ouvert par Frederik Benoist

Event ID: 2375 Date: 2016-10-25T04:46:39Z Person: Frederik Benoist Description: Ouvert par Frederik Benoist
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: fbenoist68/mobileportal#584
There is no content yet.