Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--redirect: fix check for number of columns in redirect file #359

Closed
wants to merge 3 commits into from

Conversation

haoess
Copy link
Contributor

@haoess haoess commented Jul 4, 2023

No description provided.

@kelson42 kelson42 added this to the 3.3.0 milestone Jul 4, 2023
@kelson42
Copy link
Contributor

kelson42 commented Jul 4, 2023

Not sure exactly what are the rationals behind both bug and fix. But this probably desserves a better automated testing.

@rgaudin rgaudin self-assigned this Jul 13, 2023
@rgaudin rgaudin self-requested a review July 13, 2023 15:25
Copy link
Member

@rgaudin rgaudin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a valid redirect file

 \tAccueil\tBienvenue !!\twelcome\n
 \tAccueil2\t\tcommons48.png\n
 \timage\t\tcommons48.png\n

Notice that it starts with a space and a tab \t. That space was used by the (now unused) namespace.

We have support for it in scraperlib here with a test

As per the doc, size() returns number of marked subexpressions plus 1

blame clearly shows that @mgautierfr changed the regexp 3y ago to remove the namespace but did not adjust the match count. scraperlib's implementation precedes the change.

@mgautierfr
Copy link
Collaborator

Thanks @rgaudin for the investigation.

Here's a valid redirect file [...]

Is it really a valid file ? The regex search for 2 \t (3 fields) but you have 3 \t.

@haoess Please remove the merge commit of your own PR in your own main.

@haoess It would be nice to have a testing of that code. Can you create it ? (It would probably need some refactoring of the code to separate the parsing of the file from adding the redirect)

This reverts commit e9e0f01, reversing
changes made to ac863e6.
@haoess
Copy link
Contributor Author

haoess commented Jul 17, 2023

@haoess Please remove the merge commit of your own PR in your own main.

(Hopefully) done.

@haoess It would be nice to have a testing of that code. Can you create it ?

Sorry, I’m not a C++ dev. Applying some knowledge about how other languages handle captures in RE, using a pattern with three pairs of parens (…) and testing the number of captures (+ 1 for the whole match) against 5 is not supposed to work (= what @rgaudin says).

@kelson42
Copy link
Contributor

kelson42 commented Jul 17, 2023

@mgautierfr please don't merge without automated test.

@mgautierfr
Copy link
Collaborator

(Hopefully) done.

No, I doesn't. The merge commit was the commit merging the change in your main. By reverting the merge commit, you removing the change. That's why we have 0 file changed.

Anyway, I have create #360 which takes your commit and add the tests.
So I'm closing this PR and we will continue on #360.
Thanks for your fix anyway.

@mgautierfr mgautierfr closed this Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants