Fossil

Check-in [dd490d17]
Login

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

Overview
Comment:Fix for problem reported at https://fossil-scm.org/forum/forumpost/e4953666d6 which triggered a JSON-mode assertion when trying to access a /json path via a server running in directory-serving mode (which prefixes such paths with the repo name). Such paths are now recognized as routes into the JSON API.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: dd490d17bec777c4cc26aecfa672d8c29a69292e7c867558023549c11322c553
User & Date: stephan 2020-07-08 20:26:09
References
2020-07-09
02:15
Refactored [dd490d17be] into a separate routine and applied it to the POST parsing handler to fix problem reported at https://fossil-scm.org/forum/forumpost/f3e11f5629. ... (check-in: 23e138e8 user: stephan tags: trunk)
Context
2020-07-09
02:15
Refactored [dd490d17be] into a separate routine and applied it to the POST parsing handler to fix problem reported at https://fossil-scm.org/forum/forumpost/f3e11f5629. ... (check-in: 23e138e8 user: stephan tags: trunk)
2020-07-08
20:26
Fix for problem reported at https://fossil-scm.org/forum/forumpost/e4953666d6 which triggered a JSON-mode assertion when trying to access a /json path via a server running in directory-serving mode (which prefixes such paths with the repo name). Such paths are now recognized as routes into the JSON API. ... (check-in: dd490d17 user: stephan tags: trunk)
15:23
Follow-up to previous check-in: avoid breaking external feature detection for 'mv-rm-files'. ... (check-in: 4a880a16 user: mistachkin tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/main.c.

1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
















1588
1589
1590
1591
1592
1593
1594
  ** Ensure that JSON mode is set up if we're visiting /json, to allow
  ** us to customize some following behaviour (error handling and only
  ** process JSON-mode POST data if we're actually in a /json
  ** page). This is normally set up before this routine is called, but
  ** it looks like the ssh_request_loop() approach to dispatching
  ** might bypass that.
  */
  if( g.json.isJsonMode==0 && zPathInfo!=0
      && 0==strncmp("/json",zPathInfo,5)
      && (zPathInfo[5]==0 || zPathInfo[5]=='/')){
    g.json.isJsonMode = 1;
















  }
#endif
  /* If the repository has not been opened already, then find the
  ** repository based on the first element of PATH_INFO and open it.
  */
  if( !g.repositoryOpen ){
    char *zRepo;               /* Candidate repository name */







|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
  ** Ensure that JSON mode is set up if we're visiting /json, to allow
  ** us to customize some following behaviour (error handling and only
  ** process JSON-mode POST data if we're actually in a /json
  ** page). This is normally set up before this routine is called, but
  ** it looks like the ssh_request_loop() approach to dispatching
  ** might bypass that.
  */
  if( g.json.isJsonMode==0 && zPathInfo!=0 ){
    if(0==strncmp("/json",zPathInfo,5)
       && (zPathInfo[5]==0 || zPathInfo[5]=='/')){
      g.json.isJsonMode = 1;
    }else if(g.zCmdName!=0 && 0==strcmp("server",g.zCmdName)){
      /* When running in server "directory" mode, zPathInfo is
      ** prefixed with the repository's name, so in order to determine
      ** whether or not we're really running in json mode we have to
      ** try a bit harder. Problem reported here:
      ** https://fossil-scm.org/forum/forumpost/e4953666d6
      */
      ReCompiled * pReg = 0;
      const char * zErr = re_compile(&pReg, "^/[^/]+/json(/.*)?", 0);
      assert(zErr==0 && "Regex compilation failed?");
      if(zErr==0 &&
         re_match(pReg, (const unsigned char *)zPathInfo, -1)){
        g.json.isJsonMode = 1;
      }
      re_free(pReg);
    }
  }
#endif
  /* If the repository has not been opened already, then find the
  ** repository based on the first element of PATH_INFO and open it.
  */
  if( !g.repositoryOpen ){
    char *zRepo;               /* Candidate repository name */