Fossil

Check-in [b4c961e8]
Login

Check-in [b4c961e8]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the blob_append_tcl_literal() routine to escape carriage-return characters (U+000d). Possible fix for the problem reported at forum post 390440e9793bfef7.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | diff-color-enhancements
Files: files | file ages | folders
SHA3-256: b4c961e8fb788d2b8dda2d6e2828d4e169f46fd04f314d8a2d8453a88915ebd3
User & Date: drh 2021-09-04 10:27:13
Context
2021-09-04
10:38
Fix diff.js so that it does not limit the width of unified diff <pre> elements. ... (check-in: 723ce36d user: drh tags: diff-color-enhancements)
10:27
Fix the blob_append_tcl_literal() routine to escape carriage-return characters (U+000d). Possible fix for the problem reported at forum post 390440e9793bfef7. ... (check-in: b4c961e8 user: drh tags: diff-color-enhancements)
2021-09-03
23:39
Add chunk numbers to each row of the diff output for HTML diffs. ... (check-in: 8caab615 user: drh tags: diff-color-enhancements)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/blob.c.

365
366
367
368
369
370
371

372

373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388

389
390
391
392
393
394
395
396
397
398
399
400
401
** and JSON.  Double-quotes are added to both ends.  Double-quote and
** backslash characters are escaped.
*/
void blob_append_tcl_literal(Blob *pOut, const char *z, int n){
  int i;
  blob_append_char(pOut, '"');
  for(i=0; i<n; i++){

    switch( z[i] ){

      case '[':
      case ']':
      case '$':
      case '"':
      case '\\':
        blob_append_char(pOut, '\\');
      default:
        blob_append_char(pOut, z[i]);
    }
  }
  blob_append_char(pOut, '"');
}
void blob_append_json_literal(Blob *pOut, const char *z, int n){
  int i;
  blob_append_char(pOut, '"');
  for(i=0; i<n; i++){

    switch( z[i] ){
      case '"':
      case '\\':
        blob_append_char(pOut, '\\');
      default:
        blob_append_char(pOut, z[i]);
    }
  }
  blob_append_char(pOut, '"');
}


/*







>
|
>







|








>
|




|







365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
** and JSON.  Double-quotes are added to both ends.  Double-quote and
** backslash characters are escaped.
*/
void blob_append_tcl_literal(Blob *pOut, const char *z, int n){
  int i;
  blob_append_char(pOut, '"');
  for(i=0; i<n; i++){
    char c = z[i];
    switch( c ){
      case '\r':  c = 'r';
      case '[':
      case ']':
      case '$':
      case '"':
      case '\\':
        blob_append_char(pOut, '\\');
      default:
        blob_append_char(pOut, c);
    }
  }
  blob_append_char(pOut, '"');
}
void blob_append_json_literal(Blob *pOut, const char *z, int n){
  int i;
  blob_append_char(pOut, '"');
  for(i=0; i<n; i++){
    char c = z[i];
    switch( c ){
      case '"':
      case '\\':
        blob_append_char(pOut, '\\');
      default:
        blob_append_char(pOut, c);
    }
  }
  blob_append_char(pOut, '"');
}


/*