Fossil

Check-in [d81190bd72]
Login

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

Overview
Comment:Tolerate one or two punctuation characters at the end of a symbolic name, if the name does not otherwise match, to accomodate names taken from the ends of URLs where some extra punctuation from the following text was included with the URL.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d81190bd72dcf74a8fa91b729b1d9c5bd57ee2bb1edc9a986f18a7ff19513732
User & Date: drh 2021-09-17 10:46:13.139
Context
2021-09-17
19:06
Bring the help text for the "fossil all git" command into alignment with the implementation after changes on [/timeline?c=202108141825|2021-08-14]. check-in: 1033e0ff88 user: drh tags: trunk
10:46
Tolerate one or two punctuation characters at the end of a symbolic name, if the name does not otherwise match, to accomodate names taken from the ends of URLs where some extra punctuation from the following text was included with the URL. check-in: d81190bd72 user: drh tags: trunk
02:32
Updated the JS doc's section about the hamburger menu to reflect the recent addition of this menu to other stock skins. check-in: 36d84427f6 user: wyoung tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/name.c.
222
223
224
225
226
227
228








229
230
231
232
233
234
235
        " AND event.type GLOB '%q'"
      " ORDER BY event.mtime DESC LIMIT 1"
    ") LIMIT 1;",
    zType, zTag, zTag, zType
  );
}










/*
** Convert a symbolic name into a RID.  Acceptable forms:
**
**   *  artifact hash (optionally enclosed in [...])
**   *  4-character or larger prefix of a artifact
**   *  Symbolic Name







>
>
>
>
>
>
>
>







222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
        " AND event.type GLOB '%q'"
      " ORDER BY event.mtime DESC LIMIT 1"
    ") LIMIT 1;",
    zType, zTag, zTag, zType
  );
}

/*
** Return true if character "c" is a character that might have been
** accidentally appended to the end of a URL.
*/
static int is_trailing_punct(char c){
  return c=='.' || c=='_' || c==')' || c=='>' || c=='!' || c=='?' || c==',';
}


/*
** Convert a symbolic name into a RID.  Acceptable forms:
**
**   *  artifact hash (optionally enclosed in [...])
**   *  4-character or larger prefix of a artifact
**   *  Symbolic Name
483
484
485
486
487
488
489
























490
491
492
493
494
495
496
        rid = db_int(0,
          "SELECT event.objid"
          "  FROM event"
          " WHERE event.objid=%s"
          "   AND event.type GLOB '%q'", zTag /*safe-for-%s*/, zType);
      }
    }
























  }
  return rid;
}

/*
** This routine takes a user-entered string and tries to convert it to
** an artifact hash.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
        rid = db_int(0,
          "SELECT event.objid"
          "  FROM event"
          " WHERE event.objid=%s"
          "   AND event.type GLOB '%q'", zTag /*safe-for-%s*/, zType);
      }
    }
    return rid;
  }

  /* If nothing matches and the name ends with punctuation,
  ** then the name might have originated from a URL in plain text
  ** that was incorrectly extracted from the text.  Try to remove
  ** the extra punctuation and rerun the match.
  */
  if( nTag>4
   && is_trailing_punct(zTag[nTag-1])
   && !is_trailing_punct(zTag[nTag-2])
  ){
    char *zNew = fossil_strndup(zTag, nTag-1);
    rid = symbolic_name_to_rid(zNew,zType);
    fossil_free(zNew);
  }else 
  if( nTag>5
   && is_trailing_punct(zTag[nTag-1])
   && is_trailing_punct(zTag[nTag-2])
   && !is_trailing_punct(zTag[nTag-3])
  ){
    char *zNew = fossil_strndup(zTag, nTag-2);
    rid = symbolic_name_to_rid(zNew,zType);
    fossil_free(zNew);
  }
  return rid;
}

/*
** This routine takes a user-entered string and tries to convert it to
** an artifact hash.