mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 12:49:01 +02:00
Fix progressive task output when it contains entity-escaped characters
If an update task's output contains a single quote for example (') then this will be escaped to an HTML entity before it gets sent as a response. However, that means that the length of the data in the response will be greater than the length of the original data, resulting in characters getting missed out when we read the next chunk - so we can't use the escaped length to set the next position to read from. The easiest thing to do is have the Django view send us the actual position we're at and then we don't have to try to calculate it on the JS side. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
644baaf596
commit
378413299c
|
@ -1537,16 +1537,18 @@ def task_log_view(request, task_id):
|
|||
raise Http404
|
||||
|
||||
result = AsyncResult(task_id)
|
||||
start = request.GET.get('start', 0)
|
||||
start = int(request.GET.get('start', 0))
|
||||
try:
|
||||
f = open(os.path.join(settings.TASK_LOG_DIR, 'task_%s.log' % task_id), 'rb')
|
||||
except FileNotFoundError:
|
||||
raise Http404
|
||||
try:
|
||||
f.seek(int(start))
|
||||
f.seek(start)
|
||||
# We need to escape this or else things that look like tags in the output
|
||||
# will be interpreted as such by the browser
|
||||
data = escape(f.read())
|
||||
datastr = f.read()
|
||||
origlen = len(datastr)
|
||||
data = escape(datastr)
|
||||
response = HttpResponse(data)
|
||||
if result.ready():
|
||||
response['Task-Done'] = '1'
|
||||
|
@ -1562,6 +1564,7 @@ def task_log_view(request, task_id):
|
|||
response['Task-Done'] = '0'
|
||||
preader = utils.ProgressReader(settings.TASK_LOG_DIR, task_id)
|
||||
response['Task-Progress'] = preader.read()
|
||||
response['Task-Log-Position'] = start + origlen
|
||||
finally:
|
||||
f.close()
|
||||
return response
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
if(scrolling) {
|
||||
task_log.animate({ scrollTop: task_log.prop('scrollHeight') }, "slow");
|
||||
}
|
||||
posn += data.length
|
||||
posn = xhr.getResponseHeader('Task-Log-Position');
|
||||
done = xhr.getResponseHeader('Task-Done')
|
||||
duration = xhr.getResponseHeader('Task-Duration')
|
||||
progress = parseInt(xhr.getResponseHeader('Task-Progress')) || 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user