-
-
Notifications
You must be signed in to change notification settings - Fork 19
Fix change field handling of narration (BL-16368) #7939
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -157,7 +157,31 @@ private void HandleGetDataBookValue(ApiRequest request) | |
| var dataBook = request.RequiredParam("dataBook"); | ||
| var multiText = View.Model.CurrentBook.BookData.GetMultiTextVariableOrEmpty(dataBook); | ||
| var value = multiText.GetExactAlternative(lang) ?? ""; | ||
| request.ReplyWithText(value); | ||
| var matchingDataDivElement = | ||
| View.Model.CurrentBook.RawDom.SelectSingleNode( | ||
| $"//div[@id='bloomDataDiv']/div[@data-book='{dataBook}' and @lang='{lang}']" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Do not interpolate request parameters directly into XPath; malformed or crafted values can break or alter the query. Prompt for AI agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's saying we should not put {dataBook} and {lang} into the xpath because someone might find a way to use fake values to inject something dangerous. But we do this all over, and I'm not sure what reasonable alternative there might be here. I don't think it's worth fixing.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the context—understood this isn’t a change you want to make here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Consider escaping or validating both parameters before interpolation, or use a parameterised XPath API if the underlying library supports one.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed |
||
| ) as SafeXmlElement; | ||
|
|
||
| request.ReplyWithJson( | ||
| new | ||
| { | ||
| content = value, | ||
| id = matchingDataDivElement?.GetAttribute("id"), | ||
| dataAudioRecordingMode = matchingDataDivElement?.GetAttribute( | ||
| "data-audiorecordingmode" | ||
| ), | ||
| dataDuration = matchingDataDivElement?.GetAttribute("data-duration"), | ||
| dataAudioRecordingEndTimes = matchingDataDivElement?.GetAttribute( | ||
| "data-audiorecordingendtimes" | ||
| ), | ||
| recordingMd5 = matchingDataDivElement?.GetAttribute("recordingmd5"), | ||
| hasAudioSentenceClass = matchingDataDivElement?.HasClass("audio-sentence") | ||
| ?? false, | ||
| hasBloomPostAudioSplitClass = matchingDataDivElement?.HasClass( | ||
| "bloom-postAudioSplit" | ||
| ) ?? false, | ||
| } | ||
| ); | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: The new audio-independence logic skips
TextBoxrecordings, so some kept recordings may retain shared ids instead of being duplicated with a new id.Prompt for AI agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a hallucination. The new logic calls makeEditableAudioIndependent(), which includes the passed element in the list it passes to copySoundFileAndAttributes(). The latter does copy ids and various other attributes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback! I've saved this as a new learning to improve future reviews.