overleaf / overleaf/toolkit

read_image_version assigns only a single sigit for the patch version

Open
#303 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
1.3k
Forks
310
Avg merge
3d 12h
Merged PRs (30d)
1

Description

Steps to Reproduce

  1. Have installed an overleaf image with patch version greater then 9 (ex. 3.5.13)
  2. Use a script to run the function read_image_version from lib/shared-functions.sh
  3. Read the $IMAGE_VERSION_PATCH variable
    Example code : (the file must be in the toolkit root to work)
#!/bin/bash       
TOOLKIT_ROOT="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
source lib/shared-functions.sh      
sudo echo 3.5.13 | sudo tee config/version
read_image_version
echo "$IMAGE_VERSION_MAJOR.$IMAGE_VERSION_MINOR.$IMAGE_VERSION_PATCH"

Expected Behaviour

The variable IMAGE_VERSION_PATCH should be the whole number (ex. 13) and not only the last digit (ex. 3)

Observed Behaviour

The variable $IMAGE_VERSION_PATCH contains only the last digit (ex.3)

Context

I was creating a script to automate my upgrade from overleaf version 3.0.1 to the latest (5.2.1).
While doing that i used shared-functions.sh to access it's functions and i needed to check the image version before upgrading to version 4.0.1 (needs image version > 3.5.10)

Technical Info

This is using the latest version of the toolkit

  • Operating System and version (desktop or mobile): Ubuntu server 20.04
  • Project and/or file: lib/shared-functions.sh

Analysis:

The problem is that the regex used in read_image_version is wrong.
Current regex: ^([0-9]+)\.([0-9]+)\.([0-9])+(-RC[0-9]*)?(-with-texlive-full)?$
Right regex: ^([0-9]+)\.([0-9]+)\.([0-9]+)+(-RC[0-9]*)?(-with-texlive-full)?$
The only difference is the + after the third number's regex.
You can test the regex only using websites like: https://regex101.com/

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect read_image_version in lib/shared-functions.sh, then run the provided reproduction script with config/version set to 3.5.13. Verify that IMAGE_VERSION_PATCH contains the complete patch number, including both digits, while the other version components and supported suffixes still parse correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
tooling
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.