Skip to content

fix: handle phrases with apostrophes - #116

Merged
idegtiarov merged 1 commit into
openedx:masterfrom
open-craft:agrendalath/bb-4994-handle_phrases_with_apostrophes
May 4, 2022
Merged

fix: handle phrases with apostrophes#116
idegtiarov merged 1 commit into
openedx:masterfrom
open-craft:agrendalath/bb-4994-handle_phrases_with_apostrophes

Conversation

@Agrendalath

@Agrendalath Agrendalath commented Oct 25, 2021

Copy link
Copy Markdown
Member

Description

We're using shlex to split phrases. It uses the POSIX mode by default, which is throwing an exception when there are unclosed quotes in phrases. This escapes such quotes, so the phrases with apostrophes can be split correctly.

Supporting information

OSPR ticket: OSPR-6172
OpenCraft Jira ticket: BB-4994

Known issues

The ElasticSearch connection was not working for me with the most recent devstack version. I had to add this to lms/envs/private.py and cms/envs/private.py:

ELASTIC_SEARCH_CONFIG = [
    {
        'use_ssl': False,
        'host': 'edx.devstack.elasticsearch710',
        'port': 9200
    }
]

Testing instructions

  1. Enable FEATURES['ENABLE_COURSEWARE_SEARCH'] in LMS.
  2. Enable FEATURES['ENABLE_COURSEWARE_INDEX'] in Studio.
  3. Create a Blank Common Problem XBlock with the following content:
    This should not have failed.
    This shouldn't have failed.
    This shouldn't've failed.
    This shou'dn't've failed.
    
  4. Go to your dashboard in LMS and search for the following phrases:
    • "should not"
    • shouldn't
    • shouldn\'t
    • "shouldn't have"
    • shouldn\'t\'ve
    • "shouldn't've failed"
    • shou'dn't've
    • shou\'dn\'t\'ve
    • "shou'dn't've failed"

Deadline

"None"

Reviewers

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 25, 2021
@openedx-webhooks

openedx-webhooks commented Oct 25, 2021

Copy link
Copy Markdown

Thanks for the pull request, @Agrendalath! I've created OSPR-6172 to keep track of it in JIRA, where we prioritize reviews. Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@openedx-webhooks openedx-webhooks added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Oct 25, 2021
@Agrendalath
Agrendalath force-pushed the agrendalath/bb-4994-handle_phrases_with_apostrophes branch 2 times, most recently from 6547de3 to 9aae08a Compare October 25, 2021 22:33
@Agrendalath
Agrendalath marked this pull request as ready for review October 25, 2021 22:55
@openedx-webhooks openedx-webhooks added needs triage and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Oct 25, 2021
@natabene

Copy link
Copy Markdown

@Agrendalath Thank you for your contribution. Please let me know once this is ready.

@openedx-webhooks openedx-webhooks added waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. and removed needs triage labels Oct 26, 2021
@alfredchavez

alfredchavez commented Nov 1, 2021

Copy link
Copy Markdown

👍🏽

  • I tested this: checked that the code works as expected(following described steps)
  • I read through the code

@Agrendalath

Copy link
Copy Markdown
Member Author

@natabene, this is ready for your review.
cc: @giovannicimolin, would you mind adding this to the OSPR list?

@openedx-webhooks openedx-webhooks added awaiting prioritization and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Nov 4, 2021
@giovannicimolin

Copy link
Copy Markdown

@Agrendalath I've added this one and https://github.com/edx/edx-platform/pull/29106 to the OSPR list.
With the recent changes in the community roles, @nizarmah is the new OSPR liaison assignee.

@Agrendalath
Agrendalath force-pushed the agrendalath/bb-4994-handle_phrases_with_apostrophes branch from 9aae08a to bb2bfce Compare April 8, 2022 13:43
We're using shlex to split phrases. It uses the POSIX mode by default, which is
throwing an exception when there are unclosed quotes in phrases. This disables
the POSIX mode after an error, so the phrases can still be split correctly.
@Agrendalath

Copy link
Copy Markdown
Member Author

@natabene, just a friendly reminder about this PR. It only handles an error that occurs when there is an uneven number of quotes in a search query.

@idegtiarov idegtiarov left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you for the PR.

LGTM!

@idegtiarov
idegtiarov merged commit ad9cee4 into openedx:master May 4, 2022
@openedx-webhooks

Copy link
Copy Markdown

@Agrendalath 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@Agrendalath
Agrendalath deleted the agrendalath/bb-4994-handle_phrases_with_apostrophes branch May 4, 2022 16:52
@Agrendalath

Copy link
Copy Markdown
Member Author

Thanks for a quick review, @idegtiarov!

salman2013 pushed a commit that referenced this pull request Jun 21, 2023
We're using shlex to split phrases. It uses the POSIX mode by default, which is
throwing an exception when there are unclosed quotes in phrases. This disables
the POSIX mode after an error, so the phrases can still be split correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged open-source-contribution PR author is not from Axim or 2U

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants