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

rest-api: When finding table items by cell value, ignore BiDi control chars #33

Merged
merged 4 commits into from Jun 8, 2021

Conversation

mvidner
Copy link
Member

@mvidner mvidner commented May 19, 2021

In yast/yast-storage-ng#873 I have fixed displaying filesystem paths in partitioner table widgets in right to left languages, by adding invisible BiDirectional control characters to the paths (which Qt then interprets and lays out the text correctly).

Part of that was adjusting the unit tests that were comparing table cell values to cope with the added characters and strip them off before comparing with expected values. What I haven't expected, similar comparisons are done by production code, namely here by libyui-rest-api when choosing widgets and their items by their text values.

The fix is to strip the BiDi control characters before the comparison.

openQA includes an automated test. Here is a manual test:

YUI_HTTP_REMOTE=1 YUI_REUSE_PORT=1 YUI_HTTP_PORT=9999 yast2 disk &
# now press Enter to confirm that you're not afraid of touching disks
# now select one of the partitions to move the cursor away from the whole disk, `/dev/vda`
# edit the disk name below if you have `sda` instead
curl -v -X POST 'http://localhost:9999/v1/widgets?id=%22Y2Partitioner::Widgets::ConfigurableBlkDevicesTable%22&action=select&value=/dev/vda'
# response to the above command will be 200 OK and the cursor will move
  • recently libyui-rest-api was improved to disregard the & keyboard shortcut marker in widget labels. This PR should take that into account and use similar code.
  • version + changelog

Copy link
Contributor

@shundhammer shundhammer left a comment

Choose a reason for hiding this comment

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

LGTM.

Now we'll have to rely on our QA people to check this in the real openQA machinery.

@mvidner mvidner marked this pull request as ready for review June 4, 2021 08:38
@@ -90,7 +90,7 @@ YTableActionHandler::table_findItem( std::vector<std::string>::const_iterator pa
if ( ! item )
return nullptr;

if ( item->label(column_id) == *path_begin )
if ( normalize_label ( item->label(column_id) ) == *path_begin )
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the actual fix.

Copy link
Contributor

@shundhammer shundhammer left a comment

Choose a reason for hiding this comment

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

It took me a while to understand how that remove_if() works (in true STL manner, designed in a mathematically correct way, but not at all practically oriented, let alone easy to understand; that's why I prefer Qt's string and container classes), but now that I got that,

LGTM.

@mvidner mvidner merged commit 757c3f5 into master Jun 8, 2021
@mvidner mvidner deleted the match-ignoring-bidi branch June 8, 2021 09:45
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.

None yet

2 participants